| 1 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Data::Deep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Ultimate tool for Perl data manipulation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ### Deep.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Copyright (c) 2005 Matthieu Damerose. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | Data::Deep - Complexe Data Structure analysis and manipulation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | use Data::Deep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | $dom1=[ \{'toto' => 12}, 33, {o=>5,d=>12}, 'titi' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | $dom2=[ \{'toto' => 12, E=>3},{d=>12,o=>5}, 'titi' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | my @patch = compare($dom1, $dom2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | use Data::Deep qw(:DEFAULT :convert :config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | o_complex(1); # deeper analysis results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | print join("\n", domPatch2TEXT( @patch ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | @patch = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 'add(@0$,@0$%E)=3','remove(@1,)=33','move(@2,@1)=','move(@3,@2)=' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | $dom2 = applyPatch($dom1,@patch); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | @list_found = search($dom1, ['@',1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | @list_found = search($dom1, patternText2Dom('@1')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | Data::Deep provides search, path, compare and applyPatch functions which may operate on complex Perl Data Structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | for introspection, usage and manipulation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | (ref, hash or array, array of hash, blessed object and siple scalar). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | Package, Filehandles and functions are partially supported (type and location is considered). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | Loop circular references are also considered as a $t1 variable and partially supported. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | =head2 path definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | path expression identify the current element node location in a complex Perl data structure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | pattern used in function search is used to match a part of this path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | Path is composed internally of an array of following elements : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ('%', '<key>') to match a hash table at <key> value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ('@', <index>) to match an array at specified index value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ('*', '<glob name>') to match a global reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ('|', '<module name>') to match a blessed module reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ('$') to match a reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ('&') to match a code reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ('$loop') to match a loop reference (circular reference) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ('=' <value>) to match the leaf node <value> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | In text mode a keyname may be defined by entering an hash-ref of keys in o_key() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | then '/keyname' will appears in the path text results or could be provided | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | to convert function textPatch2dom() and patternText2dom() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | Modifier <?> can be placed in the path with types to checks : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ?% : match with hash-table content (any key match) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ?@ : match with an array content (any index match) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ?= : any value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ?* : any glob type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ?$ : any reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ?=%@ : any value, hash-table or array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ?%@*|$&= : everything | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | Evaluation function : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | sub{... test with $_ ... } will be executed to match the node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | EX: sub { /\d{2,}/ } match numbers of minimal size of two | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | Patch is a directional operation to apply difference between two nodes resulting from compare($a, $b) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | Patch allow the $a complex perl data structure to be changed to $b using applyPatch($a,@patch) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | Each Patch operation is composed of : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | - an action : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 'add' for addition of an element from source to destination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 'remove' is the suppression from source to destination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 'move' if possible the move of a value or Perl Dom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 'change' describe the modification of a value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 'erase' is managed internally for array cleanup when using 'move' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | - a source path on which the value is taken from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | - a destination path on which is applied the change (most of the time same as source) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | Three patch formats can be use : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | - dom : interaction with search, path, compare, ApplyPatch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | - text : programmer facilities to use a single scalar for a patch operation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | - ihm : a small readble IHM text aim for output only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | Convert function may operation the change between this formats. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | DOM : dom patch hash-ref sample | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | EX: my $patch1 = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | { action=>'change', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | path_orig=>['@0','$','%a'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | path_dest=>['@0','$','%a'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | val_orig=>"toto", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | val_dest=>"tata" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | TEXT : text output mode patch could be : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | add(<path source>,<path destination>)=<val dest> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | remove(<path source>,<path destination>)=<val src> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | change(<path source>,<path destination>)=<val src>/=><val dest> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | move(<path source>,<path destination>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | =head2 Important note : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | * search() and path() functions use paths in "dom" format : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | DOM (simple array of elements described above) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | EX: ['@',1,'%','r','=',432] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | * applyPath() can use TEXT or DOM patch format in input. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | * compare() produce "dom" patch format in output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | All function prefer the use of dom (internal format) then no convertion is done. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | Output (user point of view) is text or ihm. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | format patches dom can be converted to TEXT : domPatch2TEXT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | format patches text can be converted to DOM : textPatch2DOM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | format patches dom can be converted to IHM : domPatch2IHM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | See conversion function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # General version and rules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | use 5.004; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | $VERSION = '0.13'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | #$| = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # Module dep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | no integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | use overload; require Exporter; our @ISA = qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | our @DEFAULT = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | travel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | visitor_patch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | visitor_dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | visitor_perl_dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | compare | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | applyPatch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | __d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | our @EXPORT = @DEFAULT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | our @CONFIG = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | o_debug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | o_follow_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | o_complex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | o_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | our @CONVERT = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | patternText2Dom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | patternDom2Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | textPatch2DOM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | domPatch2TEXT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | domPatch2IHM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | our @EXPORT_OK = (@DEFAULT, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | @CONFIG, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | @CONVERT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | our %EXPORT_TAGS=( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | convert=>[@CONVERT], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | config=>[@CONFIG] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | #/````````````````````````````````````````````````````````````````````````````\ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | my $CONSOLE_LINE=78; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | =head2 Options Methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | =item I<zap>(<array of path>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | configure nodes to skip (in search or compare) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | without parameter will return those nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub zap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
zap: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | @_ and $Data::Deep::CFG->{zap}=shift() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | or return $Data::Deep::CFG->{zap}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and $Data::Deep::CFG->{"zap"} = shift()
MC/DC0%0/2
@_ and $Data::Deep::CFG->{"zap"} = shift()
@_
$Data::Deep::CFG->{"zap"} = shift()
Truth table0%0/3
A and B
A= @_B= $Data::Deep::CFG->{"zap"} = shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ############################################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ### OPTIONS DECLARATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # Declare option : _opt_dcl 'o_flg' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # Read the option : o_flg() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # Set the option : o_flg(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | our $CFG = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | ▶ | my $__opt_dcl = sub { my $name = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | ▶ | my $proto = shift() || '$'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || '$'
MC/DC0%0/1
shift() || '$'
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 3 | ▶ | eval 'sub '.$name."(;$proto) {" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
o_complex: called CC=3 SCAR=11.5
Subroutine
o_debug: called CC=3 SCAR=11.5
Subroutine
o_follow_ref: called CC=3 SCAR=11.5
Pod
documented
Pod
documented
Pod
documented
Branch: 3 branches
Condition66%6/9
@_ and $Data::Deep::CFG->{"o_complex"} = shift()
@_ and $Data::Deep::CFG->{"o_debug"} = shift()
@_ and $Data::Deep::CFG->{"o_follow_ref"} = shift()
MC/DC100%2/2
@_ and $Data::Deep::CFG->{"o_complex"} = shift()
@_
$Data::Deep::CFG->{"o_complex"} = shift()
MC/DC0%0/2
@_ and $Data::Deep::CFG->{"o_debug"} = shift()
@_
$Data::Deep::CFG->{"o_debug"} = shift()
MC/DC0%0/2
@_ and $Data::Deep::CFG->{"o_follow_ref"} = shift()
@_
$Data::Deep::CFG->{"o_follow_ref"} = shift()
Truth table100%3/3
A and B
A= @_B= $Data::Deep::CFG->{"o_complex"} = shift()
Truth table66%2/3
A and B
A= @_B= $Data::Deep::CFG->{"o_debug"} = shift()
Truth table33%1/3
A and B
A= @_B= $Data::Deep::CFG->{"o_follow_ref"} = shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | .' @_ and $Data::Deep::CFG->{'.$name.'}=shift() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | or return $Data::Deep::CFG->{'.$name.'} }'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | ▶ | $@ and die '__bool_opt_dcl('.$name.') : '.$@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | =item I<o_debug>([<debug mode>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | debug mode : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 1: set debug mode on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0: set debug mode off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | undef : return debug mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | $__opt_dcl->('o_debug'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | =item I<o_follow_ref>([<follow mode>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | follow mode : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1: follow every reference (default) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0: do not enter into any reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | undef: return if reference are followed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | $__opt_dcl->('o_follow_ref'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | o_follow_ref(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | =item I<o_complex>([<complex mode>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | complex mode is used for intelligency complex (EX: elements move in an array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1: complex mode used in search() & compare() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0: simple analysis (no complex search) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | undef: return if reference are followed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | $__opt_dcl->('o_complex'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 11422 | ▶ | sub debug { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=6 SCAR=34.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 11422 | ▶ | o_debug() or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # B.S./WIN : no output using STDERR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub out__ { (($^O=~/win/i)?print @_:print SDTERR @_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
out__: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | foreach $l(@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | (ref $l) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | and out__ "\n".__d($l) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $l and out__("\n" . __d($l))
MC/DC0%0/2
ref $l and out__("\n" . __d($l))
ref $l
out__("\n" . __d($l))
Truth table0%0/3
A and B
A= ref $lB= out__("\n" . __d($l))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | out__$l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if (length($l)>$CONSOLE_LINE) { out__ "\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | else { out__ ' ' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | out__ "\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1831 | ▶ | sub __d { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__d: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 1831 | my $res = join('', travel(shift(), \&visitor_perl_dump)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 1831 | $res =~ s/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ([\000-\037]|[\177-\377]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 31 | /sprintf("\\%o", ord ($1))/egx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1831 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # PRIVATE FX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 6647 | ▶ | my $matchPath = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=28 SCAR=33.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 6647 | my @pattern=@{shift()}; # to match | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 6647 | my @where=@_; # current path | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # warn 'matchPath('.join(' ',@where).' , '.join(' ',@pattern).')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 6647 | my $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # warn 'matchPath:LongAlgo( '.join(' ',@pattern).', '.join(' ',@where).' )'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 6647 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 6647 | ▶ | PATH:while ($i<=$#where) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 28415 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 28415 | my $sav_i = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 28415 | ▶ | PATTERN: while ($i<=$#where) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | ### CURRENT PATH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 29471 | my $t_where = $where[$i++]; # TYPE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ## PATTERN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 29471 | my $t_patt = $pattern[$j++]; # TYPE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 29471 | ▶ | if ($t_patt eq '/') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | die 'internal matchPath('.join('',@pattern).') : key usage is only in textual format (use Text and convertion patternText2Dom)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | #print "$t_where =~ $t_patt : "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 29471 | ▶ | (index($t_patt,$t_where)==-1) and last PATTERN; # type where should be found in the pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 7569 | ▶ | if ($t_where eq '&') { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | elsif ($t_where eq '$') { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | ▶ | elsif ($t_where eq '=' or | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%12/12
$t_where eq "=" or $t_where eq "%" or $t_where eq "\@" or $t_where eq "*" or $t_where eq "|"
$t_where eq "=" or $t_where eq "%" or $t_where eq "\@" or $t_where eq "*"
$t_where eq "=" or $t_where eq "%" or $t_where eq "\@"
$t_where eq "=" or $t_where eq "%"
MC/DC100%5/5
$t_where eq "=" or $t_where eq "%" or $t_where eq "\@" or $t_where eq "*" or $t_where eq "|"
$t_where eq "="
$t_where eq "%"
$t_where eq "\@"
$t_where eq "*"
$t_where eq "|"
Truth table100%6/6
A or B or C or D or E
A= $t_where eq "="B= $t_where eq "%"C= $t_where eq "\@"D= $t_where eq "*"E= $t_where eq "|"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | $t_where eq '%' or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | $t_where eq '@' or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | $t_where eq '*' or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | $t_where eq '|' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 7428 | my $v_where = $where[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 7428 | ▶ | unless (substr($t_patt,0,1) eq '?') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | #print 'v'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 6306 | my $v_patt = $pattern[$j++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 6306 | ▶ | if (ref($v_patt) eq 'CODE') { # regexp or complexe val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 431 | local ($_) = ($v_where); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 431 | ▶ | $v_patt->($_) or last PATTERN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ▶ | elsif (ref($v_patt) and (__d($v_patt) ne __d($v_where))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $v_patt and __d($v_patt) ne __d($v_where)
MC/DC0%0/2
ref $v_patt and __d($v_patt) ne __d($v_where)
ref $v_patt
__d($v_patt) ne __d($v_where)
Truth table33%1/3
A and B
A= ref $v_pattB= __d($v_patt) ne __d($v_where)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | last PATTERN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | ▶ | elsif (!defined($v_where) and defined($v_patt)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not defined $v_where and defined $v_patt
MC/DC50%1/2
not defined $v_where and defined $v_patt
not defined $v_where
defined $v_patt
Truth table66%2/3
not(A) and B
A= not defined $v_whereB= defined $v_patt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # print '!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 815 | last PATTERN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ▶ | elsif (defined($v_where) and !defined($v_patt)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $v_where and not defined $v_patt
MC/DC50%1/2
defined $v_where and not defined $v_patt
defined $v_where
not defined $v_patt
Truth table66%2/3
A and not(B)
A= defined $v_whereB= not defined $v_patt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # print '!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 3 | last PATTERN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ▶ | elsif (defined($v_where) and defined($v_patt) and $v_patt ne $v_where) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
defined $v_where and defined $v_patt and $v_patt ne $v_where
defined $v_where and defined $v_patt
MC/DC33%1/3
defined $v_where and defined $v_patt and $v_patt ne $v_where
defined $v_where
defined $v_patt
$v_patt ne $v_where
Truth table50%2/4
A and B and C
A= defined $v_whereB= defined $v_pattC= $v_patt ne $v_where
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # print '!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 4564 | last PATTERN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | #print '#'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 56 | ▶ | ($i-1==$#where) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | die 'Error in matched expression "'.join('',@where).'" not supported char type "'.$t_where.'".'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | #print '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1842 | ▶ | if ($j-1==$#pattern and $i-1==$#where) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$j - 1 == $#pattern and $i - 1 == $#where
MC/DC100%2/2
$j - 1 == $#pattern and $i - 1 == $#where
$j - 1 == $#pattern
$i - 1 == $#where
Truth table100%3/3
A and B
A= $j - 1 == $#patternB= $i - 1 == $#where
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # warn "#found($i,$j)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 304 | return $sav_i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | }# PATTERN: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # next time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 28111 | ▶ | ($j>1) and $i = $sav_i+1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | }# WHERE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | #print "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 6343 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # KEY DCL : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 4 | ▶ | sub o_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
o_key: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | @_ and $CFG->{o_key}=shift() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 4 | ▶ | or return $CFG->{o_key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and $Data::Deep::CFG->{"o_key"} = shift()
MC/DC50%1/2
@_ and $Data::Deep::CFG->{"o_key"} = shift()
@_
$Data::Deep::CFG->{"o_key"} = shift()
Truth table66%2/3
A and B
A= @_B= $Data::Deep::CFG->{"o_key"} = shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | =item I<o_key>(<hash of key path>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | key is a search pattern for simplifying search or compare. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | or a group of pattern for best identification of nodes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | hash of key path: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | key( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | CRC => {regexp=>['%','crc32'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | eval=>'{crc32}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | priority=>1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | SZ => {regexp=>['%','sz'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | eval=>'{sz}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | priority=>2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | regexp : path to search in the dom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | eval : is the perl way to match the node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | priority : on the same node two ambigues keys are prioritized | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | depth : how many upper node to return from the current match node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 311 | ▶ | my $patchDOM = sub($$$;$$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 311 | my $action = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 311 | my $p1= shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 311 | my $p2= shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 311 | my $v1 = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 311 | my $v2 = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 311 | my $dom = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 311 | $dom->{action} = $action; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 311 | $dom->{path_orig} = $p1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 311 | $dom->{path_dest} = $p2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 311 | $dom->{val_orig} = $v1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 311 | $dom->{val_dest} = $v2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 311 | return $dom; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 330 | ▶ | my $path2eval__ = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=29 SCAR=34.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 330 | my $first_eval = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 330 | my $deepness = shift(); # [ 0.. N ] return N from root | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # [-N..-1] return N stage from leaves | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 330 | my $evaled = $first_eval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 330 | my $dbg_head = __PACKAGE__."::path2eval__(".join(',',@_).") : "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 330 | debug $dbg_head; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 330 | my $max=$#_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 330 | ▶ | @_ or return $evaled; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 314 | ▶ | if (defined $deepness and $deepness<=0) { # start from the end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $deepness and $deepness <= 0
MC/DC100%2/2
defined $deepness and $deepness <= 0
defined $deepness
$deepness <= 0
Truth table100%3/3
A and B
A= defined $deepnessB= $deepness <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 93 | ▶ | while ($deepness++<0 and $max>=0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$deepness++ < 0 and $max >= 0
MC/DC100%2/2
$deepness++ < 0 and $max >= 0
$deepness++ < 0
$max >= 0
Truth table100%3/3
A and B
A= $deepness++ < 0B= $max >= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 85 | ▶ | $_[$max-1] =~ /^[\@%\*\|\/=]$/ and $max-=2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition71%5/7
$_[$max - 1] =~ m[^[\@%\*\|/=]$] && ($max -= 2) || $_[$max] =~ /^[\$\&]$/ && --$max
$_[$max - 1] =~ m[^[\@%\*\|/=]$] and $max -= 2
$_[$max] =~ /^[\$\&]$/ and --$max
MC/DC0%0/4
$_[$max - 1] =~ m[^[\@%\*\|/=]$] && ($max -= 2) || $_[$max] =~ /^[\$\&]$/ && --$max
$_[$max - 1] =~ m[^[\@%\*\|/=]$]
$max -= 2
$_[$max] =~ /^[\$\&]$/
--$max
Truth table14%1/7
A and B || C and D
A= $_[$max - 1] =~ m[^[\@%\*\|/=]$]B= $max -= 2C= $_[$max] =~ /^[\$\&]$/D= --$max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | $_[$max] =~ /^[\$\&]$/ and $max--; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 93 | ▶ | ($max==0) and return $evaled; # upper as root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 93 | debug "\n negative depth $deepness: -> remaining path(".join(',',@_[0..$max]).")\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 93 | $deepness=undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 314 | my $deref='->'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 314 | my $i=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 314 | ▶ | while($i<=$max) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 633 | $_ = $_[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 633 | ▶ | if ($_ eq '$') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 55 | $evaled = '${'.$evaled.'}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 55 | $deref = '->'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | elsif ($_ eq '%') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 334 | $evaled .= $deref."{'".$_[$i++]."'}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 334 | $deref=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | elsif ($_ eq '@') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 221 | $evaled .= $deref.'['.$_[$i++].']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 221 | $deref=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | elsif ($_ eq '|') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 9 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | elsif ($_ eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 6 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 6 | ▶ | my $suiv = $_[$i] or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 6 | ▶ | if ($suiv eq '%') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 2 | $evaled = '*{'.$evaled.'}{HASH}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 2 | $deref = '->'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | elsif ($suiv eq '@'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 2 | $evaled = '*{'.$evaled.'}{ARRAY}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 2 | $deref = '->'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | ▶ | elsif ($suiv eq '$' or $suiv eq '='){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$suiv eq "\$" or $suiv eq "="
MC/DC0%0/2
$suiv eq "\$" or $suiv eq "="
$suiv eq "\$"
$suiv eq "="
Truth table33%1/3
A or B
A= $suiv eq "\$"B= $suiv eq "="
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 2 | $evaled = '*{'.$evaled.'}{SCALAR}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 2 | $deref = '->'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | elsif ($_ eq '/') { # KEY->{eval} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my $keyname = $_[$i++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $THEKEY = $CFG->{o_key}{$keyname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | my $ev = $THEKEY->{eval} or die $dbg_head.'bad eval code for '.$keyname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $evaled .= $deref.$ev; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $deref=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | elsif ($_ eq '&') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 1 | $evaled = $evaled.'->()'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | elsif ($_ eq '=') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 7 | ▶ | ($i==$#_) or die $dbg_head.'bad path format : value waited in path after "="'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 7 | ▶ | if ($_[$i]=~/^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 5 | $evaled = 'int('.$evaled.'=='.$_[$i++].')' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 2 | $evaled = 'int('.$evaled.' eq \''.$_[$i++].'\')' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 7 | $deref=''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | die $dbg_head.'bad path format : Type '.$_.' not supported.' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 633 | ▶ | if (defined($deepness)) { # >0 start from root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | #print "\n positive depth $deepness:"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 73 | ▶ | last if (--$deepness==0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 314 | debug "-> $evaled #\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 314 | return $evaled; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 1 | my %loop_ref=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 13136 | ▶ | sub loop_det($;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop_det: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 13136 | my $r = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 13136 | ▶ | ref($r) or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 4687 | $r = $r.' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 4687 | ▶ | if (exists($loop_ref{$r})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 66 | debug "loop_det => LOOP".join('',@_) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 66 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 4621 | $loop_ref{$r}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 4621 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # PUBLIC FX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | =head2 Operation Methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 111 | ▶ | sub visitor_patch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
visitor_patch: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | # Visitor which create patch for dom creation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 111 | my $node = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 111 | my $depth = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 111 | my $open = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 111 | my @cur_path = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 111 | my $path = join('',@cur_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # warn $depth.($open==1?' > ':(defined($open)?' < ':' ')).join('',@cur_path).' : '.ref($node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 111 | my $ref = ref($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 111 | ▶ | if ($ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 91 | ▶ | if (!defined $open ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 49 | ▶ | ($_[-1] eq '$loop') and return 'loop('.$path.','.$path.')='; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 45 | ▶ | ($ref eq 'CODE') and return 'add('.$path.','.$path.')=sub{}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | #($ref eq 'REF') and return 'add('.$path.','.$path.')={}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 43 | ▶ | ($ref eq 'GLOB') and return 'new '.$_[-1].'()'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | elsif ($open ==1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 21 | ▶ | ($ref eq 'ARRAY') and return 'add('.$path.','.$path.')=[]'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 11 | ▶ | ($ref eq 'HASH') and return 'add('.$path.','.$path.')={}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 2 | return ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | elsif ($open ==0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | #($ref eq 'ARRAY') and return ']'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | #($ref eq 'HASH') and return '}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 21 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 63 | ▶ | defined($node) and $node = "'$node'" or $node = 'undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
defined $node and $node = "'${node}'"
MC/DC100%1/1
defined $node and $node = "'${node}'"
defined $node
Truth table100%2/2
A
A= defined $node
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 63 | pop(@cur_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 63 | pop(@cur_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 63 | $path = join('',@cur_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 63 | pop(@cur_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 63 | pop(@cur_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 63 | ▶ | ($_[-2] eq '=') and return 'add('.join('',@cur_path).','.$path.')='.$node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 43 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # get the source code => How ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # (ref($node) eq 'CODE') and return $dump.'CODE';#(&$node()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # return $dump.ref($node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 23830 | ▶ | sub visitor_perl_dump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
visitor_perl_dump: called CC=29 SCAR=34.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # Visitor to dump Perl structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 23830 | my $node = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 23830 | my $depth = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 23830 | my $open = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 23830 | my @cur_path = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 23830 | my $path = @cur_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 23830 | my $ref = ref($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 23830 | my ($realpack, $realtype, $id) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | (overload::StrVal($node) =~ /^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | # warn $depth.($open==1?' > ':(defined($open)?' < ':' ')).join('',@cur_path).' : '.ref($node)." ($realpack/$realtype/$id)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 23830 | ▶ | if ($ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 15830 | ▶ | if (!defined $open ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 9936 | ▶ | ($realpack and $realtype and $id) and $ref = $realtype; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$realpack and $realtype and $id
$realpack and $realtype
MC/DC33%1/3
$realpack and $realtype and $id
$realpack
$realtype
$id
Truth table50%2/4
A and B and C
A= $realpackB= $realtypeC= $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 9936 | ▶ | ($ref eq 'REF' or $ref eq 'SCALAR') and return '\\'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ref eq "REF" or $ref eq "SCALAR"
MC/DC100%2/2
$ref eq "REF" or $ref eq "SCALAR"
$ref eq "REF"
$ref eq "SCALAR"
Truth table100%3/3
A or B
A= $ref eq "REF"B= $ref eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 9370 | ▶ | ($ref eq 'CODE') and return 'sub { "DUMMY" }'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 9306 | ▶ | if ($_[-1] eq '$loop') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 56 | return '$t1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 9250 | ▶ | if ($ref eq 'HASH' and $_[-2] eq '%') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ref eq "HASH" and $_[-2] eq "%"
MC/DC50%1/2
$ref eq "HASH" and $_[-2] eq "%"
$ref eq "HASH"
$_[-2] eq "%"
Truth table66%2/3
A and B
A= $ref eq "HASH"B= $_[-2] eq "%"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 4584 | my @keys = sort {$a cmp $b} keys(%$node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 4584 | my $is_first = ($_[-1] eq $keys[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 4584 | ▶ | $is_first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | return '\''.$_[-1].'\'=>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 3289 | return ',\''.$_[-1].'\'=>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 4666 | ▶ | ($ref eq 'ARRAY' and $_[-2] eq '@' and $_[-1] != 0) and return ','; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$ref eq "ARRAY" and $_[-2] eq "\@" and $_[-1] != 0
$ref eq "ARRAY" and $_[-2] eq "\@"
MC/DC66%2/3
$ref eq "ARRAY" and $_[-2] eq "\@" and $_[-1] != 0
$ref eq "ARRAY"
$_[-2] eq "\@"
$_[-1] != 0
Truth table75%3/4
A and B and C
A= $ref eq "ARRAY"B= $_[-2] eq "\@"C= $_[-1] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 1380 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | elsif ($open ==1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 2947 | ▶ | ($ref eq 'ARRAY') and return '['; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 1403 | ▶ | ($ref eq 'HASH') and return '{'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 37 | ▶ | ($realtype eq 'ARRAY') and return 'bless(['; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 37 | ▶ | ($realtype eq 'HASH') and return 'bless({'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | elsif ($open ==0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2947 | ▶ | ($ref eq 'ARRAY') and return ']'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 1403 | ▶ | ($ref eq 'HASH') and return '}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 37 | ▶ | ($realtype eq 'ARRAY') and return "] , '$ref')"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 37 | ▶ | ($realtype eq 'HASH') and return "} , '$ref')"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 8000 | ▶ | (defined($node)) or return 'undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 7825 | ▶ | if ($_[-2] eq '=') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 7825 | $node=~s/\'/\\\'/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 7825 | ▶ | ($node=~/^\d+$/) and return $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 3025 | return '\''.$node.'\''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 40 | ▶ | sub visitor_dump { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
visitor_dump: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # Visitor to dump Perl structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 40 | my $node = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 40 | my $depth = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 40 | my $open = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 40 | my @cur_path = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 40 | my $path = join('',@cur_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 40 | my ($realpack, $realtype, $id) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | (overload::StrVal($node) =~ /^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 40 | ▶ | return $depth.($open==1?' > ':(defined($open)?' < ':' ')).join('',@cur_path).' : '.ref($node); #." ( $realpack/$realtype/$id)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | # IDEA : sub visitor_search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # IDEA : searching visitor to replace search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | ############################################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | # my $node = shift(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | # my $depth = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | # my $open = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | # my @cur_path = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | # if (defined $matchPath->($pattern, @cur_path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | # defined($nb_occ) and (--$nb_occ<1) and die 'STOP'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | # return $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 11782 | ▶ | sub travel($;@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
travel: called CC=25 SCAR=32.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 11782 | my $where=shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 11782 | ▶ | my $visitor = shift() || \&visitor_patch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || \&Data::Deep::visitor_patch
MC/DC100%1/1
shift() || \&Data::Deep::visitor_patch
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 11782 | ▶ | my $depth = shift()||0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 11782 | my @path = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | =item I<travel>(<dom> [,<visitor function>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | travel make the visitor function to travel through each node of the <dom> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | <dom> complexe perl data structure to travel into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | <visitor_fx>() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | Return a list path where the <pattern> argument match with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | corresponding node in the <dom> tree data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | I<EX:> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | travel( {ky=>['l','r','t',124],r=>2} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | returns ( [ '%', 'ky', '@' , 3 , '=' , 124 ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 11782 | ▶ | if (@path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 9942 | debug "travel( dom=",@path, ' is ',ref($where),")"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | #debug "return ".($arr && ' ARRAY ' || 'SCALAR'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 1840 | %loop_ref=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 33923 | ▶ | sub __appendVisitorResult { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__appendVisitorResult: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 33923 | my $is_array = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 33923 | my @list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 33923 | foreach (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 321940 | ▶ | if (defined $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 321940 | ▶ | $is_array or return $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 321940 | push(@list, $_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 33923 | return @list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 11782 | my ($k,$res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 11782 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 11782 | my $ref_type = ref $where; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | ######################################## !!!!! Modules type resolution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # if (index($ref_type,'::')!=-1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 11782 | my ($realpack, $realtype, $id) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | (overload::StrVal(scalar($where)) =~ /^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 11782 | ▶ | if ($realpack and $realtype and $id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$realpack and $realtype and $id
$realpack and $realtype
MC/DC66%2/3
$realpack and $realtype and $id
$realpack
$realtype
$id
Truth table75%3/4
A and B and C
A= $realpackB= $realtypeC= $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 40 | push @path,'|',$ref_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 40 | my $y = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 40 | ▶ | if ($realtype eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | $y=$$where; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | elsif ($realtype eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 40 | $y=\%$where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | elsif ($realtype eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | $y=\@$where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | #die $realtype.' : '.$where; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | #debug ref($y)." = $realpack -> real $realtype, $id"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 40 | $where=$y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 40 | $ref_type = $realtype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | ######################################## !!!!! Loop detection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 11782 | my @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 11782 | ▶ | if (loop_det($where)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 60 | return __appendVisitorResult(wantarray(), @res, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | &$visitor($where, $depth, undef , (@path, '$loop'))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | ######################################## !!!!! SCALAR TRAVEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 11722 | ▶ | if (!$ref_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 8029 | return __appendVisitorResult(wantarray(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | &$visitor($where, $depth , undef, (@path, '=', $where))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | ######################################## !!!!! HASH TRAVEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | elsif ($ref_type eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 1418 | @res = __appendVisitorResult(wantarray(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | &$visitor($where, $depth, 1, @path)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 1418 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 1418 | foreach $k (sort {$a cmp $b} keys(%{ $where })) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 4605 | @p = (@path, '%', $k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 4605 | @res = __appendVisitorResult(wantarray(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | &$visitor($where, $depth, undef, @p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | @res = __appendVisitorResult( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | wantarray(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 4605 | travel($where->{$k},$visitor,$depth+1, @p) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 1418 | return __appendVisitorResult( wantarray(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | &$visitor($where, $depth, 0, @path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | ######################################## !!!!! ARRAY TRAVEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | elsif ($ref_type eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 1557 | $res = &$visitor($where, $depth, 1, @path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 1557 | @res = __appendVisitorResult( wantarray(), @res, $res ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 1557 | for my $i (0..$#{ $where }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | #print "\narray $i (".$where->[$i].','.join('.',@p).")\n" if (join('_',@p)=~ /\@_1_\%_g_/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 4692 | @p = (@path, '@', $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 4692 | @res = __appendVisitorResult(wantarray(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | &$visitor($where, $depth, undef, @p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 4692 | @res = __appendVisitorResult( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | wantarray(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | travel($where->[$i],$visitor,$depth+1, @p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 1557 | return __appendVisitorResult( wantarray(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | &$visitor($where, $depth, 0, @path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | ######################################## !!!!! REFERENCE TRAVEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | ▶ | elsif ($ref_type eq 'REF' or $ref_type eq 'SCALAR') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ref_type eq "REF" or $ref_type eq "SCALAR"
MC/DC100%2/2
$ref_type eq "REF" or $ref_type eq "SCALAR"
$ref_type eq "REF"
$ref_type eq "SCALAR"
Truth table100%3/3
A or B
A= $ref_type eq "REF"B= $ref_type eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 572 | @p = (@path, "\$"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 572 | @res = __appendVisitorResult( wantarray(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | &$visitor($where, $depth, undef, @p ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | return __appendVisitorResult( wantarray(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 572 | travel( ${ $where }, $visitor, $depth+1, @p ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | else { # others types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | ######################################## !!!!! CODE TRAVEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 146 | ▶ | if ($ref_type eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 66 | @p = (@path, '&'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | ######################################## !!!!! GLOB TRAVEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | elsif ($ref_type eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 80 | my $name=$$where; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 80 | $name=~s/b^\*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 80 | @p = (@path, '*', $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | ######################################## !!!!! MODULE TRAVEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | #die $ref_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | ######################################## !!!!! GLOB TRAVEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | # cf IO::Handle or Symbol::gensym() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 146 | ▶ | if ($p[-2] eq '*') { # GLOB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 80 | for $k (qw(SCALAR ARRAY HASH)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 171 | my $gval = *$where{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 171 | ▶ | defined($gval) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 130 | ▶ | next if ($k eq "SCALAR" && ! defined $$gval); # always there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k eq "SCALAR" and not defined $$gval
MC/DC100%2/2
$k eq "SCALAR" and not defined $$gval
$k eq "SCALAR"
not defined $$gval
Truth table100%3/3
A and not(B)
A= $k eq "SCALAR"B= not defined $$gval
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 73 | return __appendVisitorResult( wantarray(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | travel($gval, $visitor, $depth+1, undef, @p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 73 | return __appendVisitorResult( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | wantarray(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | @res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | &$visitor($where, $depth, undef, @p ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 1 | my %circular_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 2759 | ▶ | sub search($$;$@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: called CC=33 SCAR=35.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 2759 | my $where = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 2759 | my $pattern = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 2759 | my $nb_occ = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 2759 | my @path=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | # warn "search for #$nb_occ (",join('',@{$pattern}),")"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | =item I<search>(<tree>, <pattern> [,<max occurrences>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | search the <pattern> into <tree> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | <tree> is a complexe perl data structure to search into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | <pattern> is an array of type description to match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | <max occ.> optional argument to limit the number of results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | if undef all results are returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | if 1 first one is returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | Return a list path where the <pattern> argument match with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | corresponding node in the <dom> tree data type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | search( {ky=>['l','r','t',124],r=>2} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | ['?@','=',124]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | Returns ( [ '%', 'ky', '@' , 3 , '=' , 124 ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | search( [5,2,3,{r=>3,h=>5},4,\{r=>4},{r=>5}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | ['%','r'], 2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | Returns (['@',3,'%','r'],['@',5,'$','%','r']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | search( [5,2,3,{r=>3},4,\3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | ['?$@%','=',sub {$_ == 3 }], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | Returns (['@',2,'=',3], ['@',3,'%','r','=',3]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | # warn "search($where / ref=".ref($where).','.$nb_occ.' ,'.join('',@path).")"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 2759 | ▶ | @path or %loop_ref=(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 2759 | ▶ | (defined($nb_occ) and ($nb_occ<1)) and return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $nb_occ and $nb_occ < 1
MC/DC0%0/2
defined $nb_occ and $nb_occ < 1
defined $nb_occ
$nb_occ < 1
Truth table66%2/3
A and B
A= defined $nb_occB= $nb_occ < 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 2759 | my $ref_type = ref $where; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 2759 | my @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 2759 | my $next = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 2759 | my @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | ######################################## !!!!! Modules type resolution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 2759 | ▶ | if ($ref_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | #if (index($where,'::')!=-1) { ## !!!!! MODULE SEARCH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 676 | my ($realpack, $realtype, $id) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | (overload::StrVal($where) =~ /^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 676 | ▶ | if ($realpack and $realtype and $id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$realpack and $realtype and $id
$realpack and $realtype
MC/DC33%1/3
$realpack and $realtype and $id
$realpack
$realtype
$id
Truth table50%2/4
A and B and C
A= $realpackB= $realtypeC= $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 11 | push @path, ('|', $ref_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 11 | $ref_type = $realtype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | #warn "$ref_type -> ($realpack, $realtype, $id )"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | ######################################## !!!!! Loop detection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 676 | ▶ | if (loop_det($where)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 2 | @p = (@path, '$loop'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | ######################################## HASH Search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | elsif ($ref_type eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 272 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 272 | foreach $k (sort {$a cmp $b} keys(%{ $where })) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 1422 | @p = (@path, '%', $k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 1422 | ▶ | if (defined $matchPath->($pattern, @p)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 64 | push @found,[@p]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 64 | ▶ | defined($nb_occ) and (--$nb_occ<1) and last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $nb_occ and --$nb_occ < 1
MC/DC50%1/2
defined $nb_occ and --$nb_occ < 1
defined $nb_occ
--$nb_occ < 1
Truth table66%2/3
A and B
A= defined $nb_occB= --$nb_occ < 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 1358 | my @res = search($where->{$k}, $pattern, $nb_occ, @p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 1358 | ▶ | @res and push @found,@res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 272 | return @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | ######################################## HASH Search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | elsif ($ref_type eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 263 | for my $i (0..$#{ $where }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 1170 | @p = (@path, '@', $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 1170 | ▶ | if (defined $matchPath->($pattern, @p)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 25 | push @found,[@p]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 25 | ▶ | defined($nb_occ) and (--$nb_occ<1) and last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $nb_occ and --$nb_occ < 1
MC/DC50%1/2
defined $nb_occ and --$nb_occ < 1
defined $nb_occ
--$nb_occ < 1
Truth table66%2/3
A and B
A= defined $nb_occB= --$nb_occ < 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 1145 | my @res = search($where->[$i], $pattern, $nb_occ, @p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 1145 | ▶ | @res and push @found,@res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 263 | return @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | ######################################## REF Search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | ▶ | elsif ($ref_type eq 'REF' or $ref_type eq 'SCALAR') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ref_type eq "REF" or $ref_type eq "SCALAR"
MC/DC100%2/2
$ref_type eq "REF" or $ref_type eq "SCALAR"
$ref_type eq "REF"
$ref_type eq "SCALAR"
Truth table100%3/3
A or B
A= $ref_type eq "REF"B= $ref_type eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 110 | @p = (@path, '$'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 110 | $next = ${ $where }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | ######################################## CODE Search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | elsif ($ref_type eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 15 | @p = (@path, '&'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | ######################################## GLOB Search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | elsif ($ref_type eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 14 | my $name = $$where; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 14 | $name=~s/^\*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 14 | @p = (@path, '*',$name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 14 | ▶ | if (defined *$where{SCALAR} and defined(${*$where{SCALAR}})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
defined *$where{"SCALAR"} and defined ${*$where{"SCALAR"};}
MC/DC50%1/2
defined *$where{"SCALAR"} and defined ${*$where{"SCALAR"};}
defined *$where{"SCALAR"}
defined ${*$where{"SCALAR"};}
Truth table66%2/3
A and B
A= defined *$where{"SCALAR"}B= defined ${*$where{"SCALAR"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 4 | $next = *$where{SCALAR}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | elsif (defined *$where{ARRAY}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 4 | $next = *$where{ARRAY}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | elsif (defined *$where{HASH}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 4 | $next = *$where{HASH}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | ###################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | else { ## !!!!! SCALAR Search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 2083 | @p = (@path, '=', $where); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | ###################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 2224 | ▶ | if (defined $matchPath->($pattern, @p)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 136 | push @found,[@p]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 136 | ▶ | defined($nb_occ) and --$nb_occ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 2224 | ▶ | if ((defined($next))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 114 | my @res = search($next, $pattern, $nb_occ, @p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 114 | ▶ | @res and push @found,@res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 2224 | return @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 108 | ▶ | sub path($$;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 108 | my $dom = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 108 | my @paths = @{shift()}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 108 | ▶ | my $father_nb = shift() or 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | =item I<path>(<tree>, <paths> [,<depth>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | gives a list of nodes pointed by <paths> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | <tree> is the complex perl data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | <paths> is the array reference of paths | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | <depth> is the depth level to return from tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | <nb> start counting from the top | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | -<nb> start counting from the leaf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 return the leaf or check the leaf with '=' or '&' types): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | * if code give the return of execution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | * scalar will check the value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | Return a list of nodes reference to the <dom> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | $eq_3 = path([5,{a=>3,b=>sub {return 'test'}}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | ['@1%a']) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | $eq_3 = path([5,{a=>3,b=>sub {return 'test'}}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | '@1%a','@1%b') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | @nodes = path([5,{a=>3,b=>sub {return 'test'}}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | ['@1%b&'], # or [['@',1,'%','b','&']] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 # return ('test') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | # -1 or 2 return ( sub { "DUMMY" } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | # -2 or 1 get the hash table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | # -3 get the root tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | )]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | @nodes = path([5,{a=>3,b=>sub {return 'test'}}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | ['@1%a'], # or [['@',1,'%','b','&']] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 # return 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | # -1 or 2 get the hash table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | # -2 or 1 get the root tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | )]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 108 | debug "path( \$dom, $#paths patch, $father_nb)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 108 | my @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 108 | foreach my $node (@paths) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 153 | ▶ | (ref($node) eq 'ARRAY') or die 'path() : pattern "'.$node.'" should be a Dom pattern ("Dom" internal array, perhaps use patternText2dom)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 153 | my @path = @{$node}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | # perl evaluation of the dom path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 153 | my $e = $path2eval__->('$dom', $father_nb, @path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 153 | my $r = eval $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 153 | debug $dom; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 153 | debug $e.' evaluated to '.__d($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 153 | ▶ | die __FILE__.' : path() '.$e.' : '.$@ if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 153 | push @nodes,$r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 108 | ▶ | return shift @nodes unless (wantarray()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 108 | return @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 936 | ▶ | sub compare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare: called CC=68 SCAR=44.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | # ############ ret : 0 if equal / 1 else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 936 | my $d1 = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 936 | my $d2 = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 936 | my (@p1,@p2,$do_resolv_patch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 936 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 757 | @p1 = @{$_[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 757 | @p2 = @{$_[1]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 179 | %loop_ref=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | # equiv TEST on each function call: if ($CFG->{o_complex} and ($#a1==-1 and $#a2==-1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 179 | ▶ | $CFG->{o_complex} and $do_resolv_patch=1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | =item I<compare>(<node origine>, <node destination>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | compare nodes from origine to destination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | nodes are complex perl data structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | Return a list of <patch in dom format> (empty if node structures are equals) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | compare( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | [{r=>new Data::Dumper([5],ui=>54},4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | [{r=>new Data::Dumper([5,2],ui=>52},4] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | return ({ action=>'add', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | { action=>'change', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | ▶ | sub searchSuffix__{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
searchSuffix__: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | my @a1=@{shift()}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | my @a2=@{shift()}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | my @patch=@{shift()}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | my @common; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | ▶ | while (@a1 and @a2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@a1 and @a2
MC/DC0%0/2
@a1 and @a2
@a1
@a2
Truth table0%0/3
A and B
A= @a1B= @a2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | $_= pop(@a1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | ▶ | ($_ eq pop(@a2)) and unshift @common,$_ or return @common | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ eq pop @a2 and unshift @common, $_
MC/DC0%0/2
$_ eq pop @a2 and unshift @common, $_
$_ eq pop @a2
unshift @common, $_
Truth table0%0/3
A and B
A= $_ eq pop @a2B= unshift @common, $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | return @common | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 53 | ▶ | sub resolve_patch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_patch: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 53 | my @patch = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 53 | my ($p1,$p2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 53 | foreach $p1 (@patch) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 108 | foreach $p2 (@patch) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 470 | ▶ | if ($p1->{action} eq 'remove' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$p1->{"action"} eq "remove" and $p2->{"action"} eq "add" and __d($p1->{"val_orig"}) eq __d($p2->{"val_dest"})
$p1->{"action"} eq "remove" and $p2->{"action"} eq "add"
MC/DC100%3/3
$p1->{"action"} eq "remove" and $p2->{"action"} eq "add" and __d($p1->{"val_orig"}) eq __d($p2->{"val_dest"})
$p1->{"action"} eq "remove"
$p2->{"action"} eq "add"
__d($p1->{"val_orig"}) eq __d($p2->{"val_dest"})
Truth table100%4/4
A and B and C
A= $p1->{"action"} eq "remove"B= $p2->{"action"} eq "add"C= __d($p1->{"val_orig"}) eq __d($p2->{"val_dest"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | $p2->{action} eq 'add' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | (__d($p1->{val_orig}) eq __d($p2->{val_dest}))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | #my @com = searchSuffix__($p1->{path_orig}, $p2->{path_dest}, \@patch); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | #@com or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | #grep({$_ eq '&'} @com) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | push @patch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | compare($p1->{val_orig}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | $p2->{val_dest}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 8 | [@{$p1->{path_orig}}], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 8 | [@{$p2->{path_dest}}] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 8 | $p1->{action}='move'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 8 | $p1->{val_orig}= $p1->{val_dest}= undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 8 | $p1->{path_dest}= $p2->{path_dest}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 8 | $p2->{action}='erase'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 53 | my $o = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 53 | ▶ | while ($o<=$#patch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 108 | ▶ | ($patch[$o]->{action} eq 'erase') and splice(@patch,$o,1) and next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$patch[$o]{"action"} eq "erase" and splice @patch, $o, 1
MC/DC50%1/2
$patch[$o]{"action"} eq "erase" and splice @patch, $o, 1
$patch[$o]{"action"} eq "erase"
splice @patch, $o, 1
Truth table66%2/3
A and B
A= $patch[$o]{"action"} eq "erase"B= splice @patch, $o, 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 100 | $o++ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | return @patch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 53 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | #warn "\nComparing ORIG(".join(@p1,'=',ref($d1)||$d1).") <> DEST(".join('.',@p2,'=',ref($d2)||$d2).")\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | # ############ ret : 0 if equal / 1 else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 936 | my @msg=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | ######################################## !!!!! Type resolution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 936 | my $ref_type = ref $d1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 936 | ▶ | if ($ref_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 446 | ▶ | ($ref_type ne ref($d2)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | return ( $patchDOM->('change', \@p1,\@p2, $d1,$d2) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | #if (index($ref_type,'::')!=-1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 379 | my ($realpack, $realtype, $id) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | (overload::StrVal($d1) =~ /^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 379 | ▶ | if ($realpack and $realtype and $id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$realpack and $realtype and $id
$realpack and $realtype
MC/DC33%1/3
$realpack and $realtype and $id
$realpack
$realtype
$id
Truth table50%2/4
A and B and C
A= $realpackB= $realtypeC= $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 2 | my ($realpack2, $realtype2, $id2) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | (overload::StrVal($d2) =~ /^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 2 | ▶ | ($realtype ne $realtype2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | push @msg, $patchDOM->('change', \@p1 ,\@p2 , $realtype ,$realtype2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 2 | push @p1, '|',$ref_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 2 | push @p2, '|',$ref_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 2 | debug "$ref_type -> ($realpack, $realtype, $id : $ref_type)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 2 | $ref_type = $realtype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | ######################################## !!!!! SCALAR COMPARE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 869 | ▶ | if (!$ref_type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 490 | ▶ | (defined($d1) and $d1 ne $d2) and return ($patchDOM->('change', \@p1,\@p2, $d1,$d2) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $d1 and $d1 ne $d2
MC/DC100%2/2
defined $d1 and $d1 ne $d2
defined $d1
$d1 ne $d2
Truth table100%3/3
A and B
A= defined $d1B= $d1 ne $d2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 407 | ▶ | (!defined($d1) and defined($d2)) and return ($patchDOM->('change', \@p1,\@p2, $d1,$d2) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $d1 and defined $d2
MC/DC100%2/2
not defined $d1 and defined $d2
not defined $d1
defined $d2
Truth table100%3/3
not(A) and B
A= not defined $d1B= defined $d2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 405 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | ######################################## !!!!! HASH COMPARE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | elsif ($ref_type eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 167 | my (%seen,$k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 167 | foreach $k (sort {$a cmp $b} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 167 | keys(%{ $d1 })) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 360 | $seen{$k}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 360 | ▶ | if (exists $d2->{$k}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 338 | ▶ | loop_det($d1->{$k},@p1) and next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | push @msg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | compare( $d1->{$k}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 338 | $d2->{$k}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | [ @p1, '%',$k ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | [ @p2, '%',$k ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 22 | push @msg,$patchDOM->('remove', [ @p1, '%', $k ] ,\@p2 , $d1->{$k} ,undef) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | }#foreach($d1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 167 | foreach $k (sort {$a cmp $b} keys(%{ $d2 })) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 361 | ▶ | next if exists $seen{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 23 | my $v = $d2->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 23 | push @msg,$patchDOM->('add', \@p1, [ @p2, '%', $k ], undef, $v) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 167 | ▶ | $do_resolv_patch or return @msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 35 | return resolve_patch(@msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | elsif ($ref_type eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | ######################################## !!!!! ARRAY COMPARE (not complex mode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 132 | ▶ | unless ($CFG->{o_complex}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 63 | my $min = $#{$d1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 63 | ▶ | $min = $#{$d2} if ($#{$d2}<$min); # min ($#{$d1},$#{$d2}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 63 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 63 | foreach $i (0..$min) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 120 | ▶ | loop_det($d1->[$i], @p1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 118 | push @msg, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | compare( $d1->[$i], $d2->[$i], [@p1, '@',$i], [@p2, '@',$i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 63 | foreach $i ($min+1..$#{$d1}) { # $d1 is bigger | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | # silent just for complexe search mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 5 | push @msg,$patchDOM->('remove', [ @p1, '@', $i ], \@p2 ,$d1->[$i], undef) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 63 | foreach $i ($#{$d1}+1..$#{$d2}) { # d2 is bigger | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 9 | push @msg,$patchDOM->('add', \@p1, [ @p2, '@', $i ], undef, $d2->[$i]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | 63 | return @msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | ######################################## !!!!! ARRAY COMPARE (in complex mode) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 69 | my @seen_src; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | my @seen_dst; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 69 | my @res_Eq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | # perhaps not on the same index (search in the dest @) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 69 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | ARRAY_CPLX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 69 | foreach $i (0..$#{$d1}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 161 | my $val1 = $d1->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | #print "\n SAR($i) {"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | #if ($i<$#{$d2}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 161 | ▶ | if (exists $d2->[$i]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 155 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 155 | ▶ | loop_det($val1, @p1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | @res = compare($val1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | $d2->[$i], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | [ @p1, '@',$i ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | [ @p2, '@',$i ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 155 | ▶ | if (@res) { $res_Eq[$i] = [@res] } # (*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 126 | $seen_src[$i]=$i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 126 | $seen_dst[$i]=$i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 126 | next ARRAY_CPLX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 35 | my $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 35 | foreach $j (0..$#{$d2}) { #print " -> $j "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | 102 | ▶ | next if ($i==$j); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 78 | ▶ | next if (defined($seen_dst[$j])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 61 | ▶ | unless (compare( $val1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | $d2->[$j], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | [ @p1, '@',$i ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | [ @p2, '@',$j ])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | { #print " (found) "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 15 | $seen_dst[$j] = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 15 | $seen_src[$i] = $patchDOM->('move', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | [ @p1, '@', $i ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | [ @p2, '@', $j ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 15 | next ARRAY_CPLX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 20 | ▶ | (defined $seen_src[$i]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | $seen_src[$i] = $patchDOM->('remove', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | [ @p1, '@', $i ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | \@p2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | $val1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | #print " }SAR($i)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | } # for $d1 (0..$min) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | ### destination table $d2 is bigger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 69 | foreach $i (0..$#{$d2}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 165 | ▶ | defined($seen_dst[$i]) and next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 24 | $seen_dst[$i] = $patchDOM->('add', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | \@p1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | [ @p2, '@', $i ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | $d2->[$i] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 69 | my $max = $#seen_dst; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 69 | ▶ | ($#seen_src>$max) and $max = $#seen_src; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 69 | foreach (0..$max) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 171 | my $src = $seen_src[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 171 | my $dst = $seen_dst[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 171 | ▶ | if (ref($res_Eq[$_]) and # differences on the same index (*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
ref $res_Eq[$_] and ref $src and ref $dst
ref $res_Eq[$_] and ref $src
MC/DC66%2/3
ref $res_Eq[$_] and ref $src and ref $dst
ref $res_Eq[$_]
ref $src
ref $dst
Truth table75%3/4
A and B and C
A= ref $res_Eq[$_]B= ref $srcC= ref $dst
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | ref($src) and ref($dst)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | #print "\n src/dst : ".domPatch2TEXT($src)."/ ".domPatch2TEXT($dst)."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | # remove(@2,)=<val1> add(,@2)=<val2 => <patch val1 val2> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | ($src->{action} eq 'remove') and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | ($dst->{action} eq 'add') and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 17 | ▶ | (push @msg, @{ $res_Eq[$_] }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$src->{"action"} eq "remove" and $dst->{"action"} eq "add" and push @msg, @{$res_Eq[$_];}
$src->{"action"} eq "remove" and $dst->{"action"} eq "add"
MC/DC33%1/3
$src->{"action"} eq "remove" and $dst->{"action"} eq "add" and push @msg, @{$res_Eq[$_];}
$src->{"action"} eq "remove"
$dst->{"action"} eq "add"
push @msg, @{$res_Eq[$_];}
Truth table50%2/4
A and B and C
A= $src->{"action"} eq "remove"B= $dst->{"action"} eq "add"C= push @msg, @{$res_Eq[$_];}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | and next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 159 | ▶ | (ref $src) and push @msg,$src; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 159 | ▶ | (ref $dst) and push @msg,$dst; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 69 | ▶ | $do_resolv_patch or return @msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 14 | return resolve_patch(@msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | ######################################## !!!!! REF COMPARE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | ▶ | elsif ($ref_type eq 'REF' or $ref_type eq 'SCALAR') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ref_type eq "REF" or $ref_type eq "SCALAR"
MC/DC100%2/2
$ref_type eq "REF" or $ref_type eq "SCALAR"
$ref_type eq "REF"
$ref_type eq "SCALAR"
Truth table100%3/3
A or B
A= $ref_type eq "REF"B= $ref_type eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 65 | ▶ | if (loop_det($$d1, @p1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 65 | @msg = ( compare($$d1, $$d2, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | [ @p1, '$' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | [ @p2, '$' ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 65 | ▶ | $do_resolv_patch or return @msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 4 | return resolve_patch(@msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | ######################################## !!!!! GLOBAL REF COMPARE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | elsif ($ref_type eq 'GLOB') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 14 | my $name1=$$d1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 14 | $name1=~s/^\*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 14 | my $name2=$$d2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 14 | $name2=~s/^\*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 14 | push @p1,'*', $name1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 14 | push @p2,'*', $name2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 14 | push @msg, $patchDOM->('change', \@p1 ,\@p2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 14 | my ($k,$g_d1,$g_d2)=(undef,undef,undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 14 | ▶ | if (defined *$d1{SCALAR} and defined(${*$d1{SCALAR}})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
defined *$d1{"SCALAR"} and defined ${*$d1{"SCALAR"};}
MC/DC50%1/2
defined *$d1{"SCALAR"} and defined ${*$d1{"SCALAR"};}
defined *$d1{"SCALAR"}
defined ${*$d1{"SCALAR"};}
Truth table66%2/3
A and B
A= defined *$d1{"SCALAR"}B= defined ${*$d1{"SCALAR"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 5 | $g_d1 = *$d1{SCALAR}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | elsif (defined *$d1{ARRAY}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | 4 | $g_d1 = *$d1{ARRAY}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | elsif (defined*$d1{HASH}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 5 | $g_d1 = *$d1{HASH}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | elsif (defined*$d1{GLOB}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 0 | $g_d1 = *$d1{GLOB}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 0 | ▶ | loop_det($g_d1, @p1) and return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | die $name1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 14 | ▶ | if (defined *$d2{SCALAR} and defined(${*$d2{SCALAR}})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
defined *$d2{"SCALAR"} and defined ${*$d2{"SCALAR"};}
MC/DC50%1/2
defined *$d2{"SCALAR"} and defined ${*$d2{"SCALAR"};}
defined *$d2{"SCALAR"}
defined ${*$d2{"SCALAR"};}
Truth table66%2/3
A and B
A= defined *$d2{"SCALAR"}B= defined ${*$d2{"SCALAR"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 4 | $g_d2 = *$d2{SCALAR}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | elsif (defined *$d2{ARRAY}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 5 | $g_d2 = *$d2{ARRAY}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | elsif (defined*$d2{HASH}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 5 | $g_d2 = *$d2{HASH}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | elsif (defined*$d2{GLOB}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | $g_d2 = *$d2{GLOB}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | die $name2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 14 | my @msg = ( compare($g_d1, $g_d2, \@p1, \@p2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 14 | ▶ | $do_resolv_patch or return @msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | return resolve_patch(@msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | ######################################## !!!!! CODE REF COMPARE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | elsif ($ref_type eq 'CODE') { # cannot compare this type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | #push @msg,$patchDOM->('change', \@p1, [@p2, '@', $i ], undef, $d2->[$i]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 1 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | ######################################## !!!!! What's that ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | 0 | die 'unknown type /'.$ref_type.'/ '.join('',@p1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 41 | ▶ | sub applyPatch($@) { # modify a dom source with a patch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
applyPatch: called CC=14 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 41 | my $dom = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | =item I<applyPatch>(<tree>, <patch 1> [, <patch N>] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | applies the patches to the <tree> (perl data structure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | <patch1> [,<patch N> ] is the list of your patches to apply | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | supported patch format should be text or dom types, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | the patch should a clear description of a modification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | no '?' modifier or ambiguities) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | Return the modified dom, die if patch are badly formated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | applyPatch([1,2,3],'add(,@4)=4') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | return [1,2,3,4] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 41 | debug 'applyPatch('.__d($dom).') :'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 41 | my (@remove,@add,@change,@move); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 41 | my $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 41 | foreach $p (@_) { # ordering the patch operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 145 | ▶ | defined($p) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 145 | my $dom_patch = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 145 | ▶ | (ref($p) eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | or ($dom_patch) = textPatch2DOM($p); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 145 | debug(domPatch2TEXT($dom_patch)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 145 | eval 'push @'.$dom_patch->{action}.', $dom_patch;'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 145 | ▶ | $@ and die 'applyPatch() : '.$@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 41 | my ($d,$t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 41 | my ($d1,$d2,$d3,$d4,$d5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 41 | my ($t1,$t2,$t3,$t4,$t5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 41 | my $patch_eval='$d='.__d($dom).";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | 41 | $patch_eval .= '$t='.__d($dom).";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | 41 | my $post_eval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | my $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 41 | foreach $r (@remove) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 23 | my @porig = @{$r->{path_orig}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 23 | my $key = pop @porig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | 23 | my $type = pop @porig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 23 | ▶ | if ($type eq '@') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 12 | $patch_eval .= 'splice @{'.$path2eval__->('$d',undef,@porig) ."},$key,1;\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | 11 | $patch_eval .= 'delete '.$path2eval__->('$d',undef,@porig,$type,$key) .";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 41 | my $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | my @remove_patch = sort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | # the array indexes order from smallest to biggest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 41 | ▶ | if (${$a->{path_orig}}[-2] eq '@') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | 4 | return (${$a->{path_orig}}[-1] > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 4 | ${$b->{path_orig}}[-1]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | # smallest path after bigger ones | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | return $#{$a->{path_orig}} < $#{$b->{path_orig}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | } @move; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 41 | foreach $m (@remove_patch) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | 16 | my @porig = @{$m->{path_orig}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 16 | my $key = pop @porig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | 16 | my $type = pop @porig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | 16 | ▶ | if ($type eq '@') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 8 | $patch_eval .= 'splice @{'.$path2eval__->('$d',undef,@porig)."},$key,1;\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 8 | $patch_eval .= 'delete '.$path2eval__->('$d',undef,@porig,$type,$key) .";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | 41 | foreach $m (@remove_patch) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 16 | my @porig = @{$m->{path_orig}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 16 | $patch_eval .= $path2eval__->('$d',undef,@{$m->{path_dest}}). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | ' = '.$path2eval__->('$t',undef,@porig).";\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 41 | my $a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 41 | foreach $a (@add) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | $patch_eval .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 38 | $path2eval__->('$d',undef,@{$a->{path_dest}}). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 38 | ' = '.__d($a->{val_dest}) .";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 41 | my $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 41 | foreach $c (@change) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | $patch_eval .= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 68 | $path2eval__->('$d',undef,@{$c->{path_dest}}). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 68 | ' = '.__d($c->{val_dest}).";\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 41 | $patch_eval = $patch_eval.'$d;'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 41 | my $res = eval($patch_eval); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 41 | debug "\nEval=>> $patch_eval >>=".__d($res).".\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 41 | ▶ | $@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | die 'applyPatch() : '.$patch_eval.$@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 41 | return $res | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | =head2 Conversion Methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 605 | ▶ | sub patternDom2Text($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
patternDom2Text: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 605 | my @path=@{shift()}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | =item I<patternDom2Text>(<pattern>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | convert the pattern DOM (array of element used by search(), path()) to text scalar string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | <pattern> is an array list of splited element of the pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | Return equivalent text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | patternDom2Text( ['?@'] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | Return '?@' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | patternDom2Text( ['%', 'r'] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | Return '%r' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | patternDom2Text( ['@',3,'%','r'] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | Return '@3%r' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | patternDom2Text( ['@',2,'=','3'] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | Return '@2=3' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | # patternDom2Text is a single join without key defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | 605 | ▶ | (defined $CFG->{o_key}) or return join('',@path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 74 | ▶ | (%{$CFG->{o_key}}) or join('',@path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | # matching Keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | 74 | my $sz_path = scalar(@path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | # debug "\n###".join('.',@{$path}).' '.join('|',keys %{$CFG->{o_key}}); <>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | 74 | my %keys=%{$CFG->{o_key}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | # TODO : key priority sould be managed by a small getPrioritizedKey() function (warning) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 74 | my @sorted_keys = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | # sort { ( $keys{$a}->{priority} > $keys{$b}->{priority} ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | keys %keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 74 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 74 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 74 | ▶ | while ($i<scalar(@path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 393 | foreach $k (@sorted_keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | 1831 | my $match = $keys{$k}{regexp}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | #warn "\n=$k on ".join('',@path[0..$i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 1831 | my $min_index = $matchPath->($match, @path[0..$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 1831 | ▶ | if (defined $min_index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | # debug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | #warn " -> key($k -> ".join(' ',@{$match}).") = $min_index\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | # replace the (matched key expression) by ('/' , <key name>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | 79 | splice @path, $min_index, scalar(@$match), '/',$k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 79 | $i = $i + 2 - scalar(@$match); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | #warn "-> path -> ".join('.',@path)." \$i=$i\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | 393 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | 74 | return join('',@path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 262 | ▶ | sub domPatch2TEXT(@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
domPatch2TEXT: called CC=12 SCAR=26.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | =item I<domPatch2TEXT>(<patch 1>, <patch 2> [,<patch N>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | convert a list of perl usable patches into a readable text format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | Also convert to key patterns which are matching the regexp key definnition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | Mainly used to convert the compare result (format dom) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | ARGS: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | a list of <patch in dom format> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | Return a list of patches in TEXT mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | domPatch2TEXT($patch1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | returns 'change(@0$%magic_key,@0$%magic_key)="toto"/=>"tata"' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | # one key defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | o_key({ key_1 => {regexp=>['%','magic_key'], eval=>'{magic_key}' } } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | # same but with the related matched key in path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | domPatch2TEXT($patch1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | returns 'change(@0$/key_1,@0$/key_1)="toto"/=>"tata"' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 262 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | my $patch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | 262 | foreach $patch (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | (ref($patch) eq 'HASH') and do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | (exists $patch->{action}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | 262 | ▶ | or die 'domPatch2TEXT(): bad internal dom structure '.__d($patch); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | 262 | my $action = $patch->{action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | 262 | my $v1 = $patch->{val_orig}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | 262 | my $v2 = $patch->{val_dest}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | my $txt = $action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | .'(' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | .patternDom2Text($patch->{path_orig}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | .',' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | .patternDom2Text($patch->{path_dest}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | 262 | .')='; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | 262 | ▶ | if (($action eq 'remove') or ($action eq 'change')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$action eq "remove" or $action eq "change"
MC/DC100%2/2
$action eq "remove" or $action eq "change"
$action eq "remove"
$action eq "change"
Truth table100%3/3
A or B
A= $action eq "remove"B= $action eq "change"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | 168 | $v1 = __d($v1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | 168 | $v1 =~ s|/=>|\/\\054\>|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 168 | $v1 =~ s/\s=>\s/=>/sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | 168 | $txt .= $v1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 262 | ▶ | ($action eq 'change') and $txt .= '/=>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | 262 | ▶ | if (($action eq 'add') or ($action eq 'change')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$action eq "add" or $action eq "change"
MC/DC100%2/2
$action eq "add" or $action eq "change"
$action eq "add"
$action eq "change"
Truth table100%3/3
A or B
A= $action eq "add"B= $action eq "change"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | 193 | $v2 = __d($v2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 193 | $v2 =~ s|/=>|\/\\054\>|g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | 193 | $v2 =~ s/\s=>\s/=>/sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 193 | $txt .= $v2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | 262 | push @res, $txt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | 262 | ▶ | } or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $_ eq "ARRAY" and do {
push @res, join("", @{$_;});
next
}
MC/DC0%0/2
ref $_ eq "ARRAY" and do {
push @res, join("", @{$_;});
next
}
ref $_ eq "ARRAY"
do {
push @res, join("", @{$_;});
next
}
Truth table0%0/3
A and B
A= ref $_ eq "ARRAY"B= do {
push @res, join("", @{$_;});
next
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | 262 | ▶ | (ref($_) eq 'ARRAY') and do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
ref $patch eq 'HASH' && do {
exists $patch->{'action'} or die 'domPatch2TEXT(): bad internal dom structure ' . __d($patch);
my $action = $patch->{'action'};
my $v1 = $patch->{'val_orig'};
my $v2 = $patch->{'val_dest'};
my $txt = $action . '(' . &patternDom2Text($patch->{'path_orig'}) . ',' . &patternDom2Text($patch->{'path_dest'}) . ')=';
if ($action eq 'remove' or $action eq 'change') {
$v1 = __d($v1);
$v1 =~ s[/=>][/\\054>]g;
$v1 =~ s/\s=>\s/=>/gs;
$txt .= $v1;
};
$action eq 'change' and $txt .= '/=>';
if ($action eq 'add' or $action eq 'change') {
$v2 = __d($v2);
$v2 =~ s[/=>][/\\054>]g;
$v2 =~ s/\s=>\s/=>/gs;
$txt .= $v2;
};
push @res, $txt;
next
} || ref $_ eq 'ARRAY' && do {
push @res, join('', @{$_;});
next
}
ref $patch eq "HASH" and do {
exists $patch->{"action"} or die 'domPatch2TEXT(): bad internal dom structure ' . __d($patch);
my $action = $patch->{"action"};
my $v1 = $patch->{"val_orig"};
my $v2 = $patch->{"val_dest"};
my $txt = $action . '(' . &patternDom2Text($patch->{"path_orig"}) . ',' . &patternDom2Text($patch->{"path_dest"}) . ')=';
if ($action eq "remove" or $action eq "change") {
$v1 = __d($v1);
$v1 =~ s[/=>][/\\054>]g;
$v1 =~ s/\s=>\s/=>/gs;
$txt .= $v1;
};
$action eq "change" and $txt .= '/=>';
if ($action eq "add" or $action eq "change") {
$v2 = __d($v2);
$v2 =~ s[/=>][/\\054>]g;
$v2 =~ s/\s=>\s/=>/gs;
$txt .= $v2;
};
push @res, $txt;
next
}
MC/DC0%0/3
ref $patch eq 'HASH' && do {
exists $patch->{'action'} or die 'domPatch2TEXT(): bad internal dom structure ' . __d($patch);
my $action = $patch->{'action'};
my $v1 = $patch->{'val_orig'};
my $v2 = $patch->{'val_dest'};
my $txt = $action . '(' . &patternDom2Text($patch->{'path_orig'}) . ',' . &patternDom2Text($patch->{'path_dest'}) . ')=';
if ($action eq 'remove' or $action eq 'change') {
$v1 = __d($v1);
$v1 =~ s[/=>][/\\054>]g;
$v1 =~ s/\s=>\s/=>/gs;
$txt .= $v1;
};
$action eq 'change' and $txt .= '/=>';
if ($action eq 'add' or $action eq 'change') {
$v2 = __d($v2);
$v2 =~ s[/=>][/\\054>]g;
$v2 =~ s/\s=>\s/=>/gs;
$txt .= $v2;
};
push @res, $txt;
next
} || ref $_ eq 'ARRAY' && do {
push @res, join('', @{$_;});
next
}
ref $patch eq "HASH"
do {
exists $patch->{"action"} or die 'domPatch2TEXT(): bad internal dom structure ' . __d($patch);
my $action = $patch->{"action"};
my $v1 = $patch->{"val_orig"};
my $v2 = $patch->{"val_dest"};
my $txt = $action . '(' . &patternDom2Text($patch->{"path_orig"}) . ',' . &patternDom2Text($patch->{"path_dest"}) . ')=';
if ($action eq "remove" or $action eq "change") {
$v1 = __d($v1);
$v1 =~ s[/=>][/\\054>]g;
$v1 =~ s/\s=>\s/=>/gs;
$txt .= $v1;
};
$action eq "change" and $txt .= '/=>';
if ($action eq "add" or $action eq "change") {
$v2 = __d($v2);
$v2 =~ s[/=>][/\\054>]g;
$v2 =~ s/\s=>\s/=>/gs;
$txt .= $v2;
};
push @res, $txt;
next
}
ref $_ eq 'ARRAY' && do {
push @res, join('', @{$_;});
next
}
Truth table0%0/5
A and B || C
A= ref $patch eq "HASH"B= do {
exists $patch->{"action"} or die 'domPatch2TEXT(): bad internal dom structure ' . __d($patch);
my $action = $patch->{"action"};
my $v1 = $patch->{"val_orig"};
my $v2 = $patch->{"val_dest"};
my $txt = $action . '(' . &patternDom2Text($patch->{"path_orig"}) . ',' . &patternDom2Text($patch->{"path_dest"}) . ')=';
if ($action eq "remove" or $action eq "change") {
$v1 = __d($v1);
$v1 =~ s[/=>][/\\054>]g;
$v1 =~ s/\s=>\s/=>/gs;
$txt .= $v1;
};
$action eq "change" and $txt .= '/=>';
if ($action eq "add" or $action eq "change") {
$v2 = __d($v2);
$v2 =~ s[/=>][/\\054>]g;
$v2 =~ s/\s=>\s/=>/gs;
$txt .= $v2;
};
push @res, $txt;
next
}C= ref $_ eq 'ARRAY' && do {
push @res, join('', @{$_;});
next
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 0 | push @res,join '', @{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | 262 | ▶ | (wantarray()) and return @res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | 2 | return join("\n",@res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | 0 | ▶ | sub domPatch2IHM(@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
domPatch2IHM: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | =item I<domPatch2IHM>(<patch 1>, <patch 2> [,<patch N>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | convert a list of patches in DOM format (internal Data;;Deep format) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | into a IHM format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | Mainly used to convert the compare result (format dom) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | ARGS: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | a list of <patch in dom format> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | Return a list of patches in IHM mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | IHM format is not convertible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | C<domPatch2IHM>($patch1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | '"toto" changed in "tata" from @0$%a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | into @0$%a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | 0 | my ($msg,$patch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | 0 | foreach $patch (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | 0 | $_ = $patch->{action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | /^add$/ and ($msg .= __d($patch->{val_orig}).' added') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | /^remove$/ and ($msg .= __d($patch->{val_orig}).' removed') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | /^move$/ and ($msg .= 'Moved ') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | /^change$/ and ($msg .= __d($patch->{val_orig}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | .' changed in ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | ▶ | .__d($patch->{val_dest})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/17
/^add$/ && ($msg .= __d($patch->{'val_orig'}) . ' added') || /^remove$/ && ($msg .= __d($patch->{'val_orig'}) . ' removed') || /^move$/ && ($msg .= 'Moved ') || /^change$/ && ($msg .= __d($patch->{'val_orig'}) . ' changed in ' . __d($patch->{'val_dest'}))
/^add$/ and $msg .= __d($patch->{"val_orig"}) . ' added' or /^remove$/ and $msg .= __d($patch->{"val_orig"}) . ' removed' or /^move$/ and $msg .= 'Moved '
/^add$/ and $msg .= __d($patch->{"val_orig"}) . ' added' or /^remove$/ and $msg .= __d($patch->{"val_orig"}) . ' removed'
/^add$/ and $msg .= __d($patch->{"val_orig"}) . ' added'
/^remove$/ and $msg .= __d($patch->{"val_orig"}) . ' removed'
/^move$/ and $msg .= 'Moved '
/^change$/ and $msg .= __d($patch->{"val_orig"}) . ' changed in ' . __d($patch->{"val_dest"})
MC/DC0%0/4
/^add$/ && ($msg .= __d($patch->{'val_orig'}) . ' added') || /^remove$/ && ($msg .= __d($patch->{'val_orig'}) . ' removed') || /^move$/ && ($msg .= 'Moved ') || /^change$/ && ($msg .= __d($patch->{'val_orig'}) . ' changed in ' . __d($patch->{'val_dest'}))
/^add$/
/^remove$/
/^move$/
/^change$/
Truth table0%0/5
A or B or C || D
A= /^add$/B= /^remove$/C= /^move$/D= /^change$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | 0 | my $l = length($msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | my $MAX_COLS=40; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | 0 | ▶ | if ($l>$MAX_COLS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | $msg .= "\n from ".join('',@{$patch->{path_orig}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | 0 | $msg .= "\n into ".join('',@{$patch->{path_dest}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | 0 | $l-=($msg=~ s/\n//g); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | 0 | $msg .= ' from '.join('',@{$patch->{path_orig}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | 0 | $msg .= "\n".(' 'x $l).' into '.join('',@{$patch->{path_dest}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | $msg .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | 0 | return $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | 82 | ▶ | sub patternText2Dom($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
patternText2Dom: called CC=17 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 82 | my $pathTxt = shift(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | 82 | ▶ | (ref($pathTxt)) and die 'patternText2Dom() : bad call with a reference instead of scalar containing pattern text '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | =item I<patternText2Dom>(<text pattern>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | convert pattern scalar string to the array of element to be used by search(), path() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | <pattern> is an array of type description to match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | <max occ.> optional argument to limit the number of results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | if undef all results are returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | if 1 first one is returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | Return an array list of splited element of the <pattern> for usage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | patternText2Dom( '?@' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | Return ['?@'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | patternText2Dom( '%r' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | Return '%', r'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | patternText2Dom( '@3%r' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | Return ['@',3,'%','r'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | patternText2Dom( '@2=3' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | Return ['@',2,'=','3'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | 82 | my @path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | #debug "patternText2Dom($pathTxt)";; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | 82 | my %keys=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | 82 | ▶ | (ref($CFG->{o_key})) and %keys = %{$CFG->{o_key}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | 82 | my @pathTxt = split('',$pathTxt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | 82 | ▶ | while (@pathTxt) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | 427 | $_ = shift @pathTxt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | 427 | ▶ | if (defined($path[-1]) and $path[-1] =~ /^\?/ and m/^[\=\%\$\@\%\*]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition83%5/6
defined $path[-1] and $path[-1] =~ /^\?/ and /^[\=\%\$\@\%\*]/
defined $path[-1] and $path[-1] =~ /^\?/
MC/DC66%2/3
defined $path[-1] and $path[-1] =~ /^\?/ and /^[\=\%\$\@\%\*]/
defined $path[-1]
$path[-1] =~ /^\?/
/^[\=\%\$\@\%\*]/
Truth table75%3/4
A and B and C
A= defined $path[-1]B= $path[-1] =~ /^\?/C= /^[\=\%\$\@\%\*]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | 3 | $path[-1].= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | elsif ($_ eq '$') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | 22 | push(@path,'$'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | elsif ($_ eq '?') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | 3 | push(@path,'?'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | elsif ($_ eq '&') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | 3 | push(@path,'&'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | elsif (/([%\@\=\|\*\/])/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | 144 | push(@path,$1,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | 252 | ▶ | if ($path[-2] eq '/' and exists($keys{$path[-1]})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$path[-2] eq "/" and exists $keys{$path[-1]}
MC/DC100%2/2
$path[-2] eq "/" and exists $keys{$path[-1]}
$path[-2] eq "/"
exists $keys{$path[-1]}
Truth table100%3/3
A and B
A= $path[-2] eq "/"B= exists $keys{$path[-1]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | # cf test "Search Complex key 3..5" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | 3 | push(@path,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | 252 | $path[-1].= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | # post - convertion of array & key convertion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | 82 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | 82 | for $i (0..$#path) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | 319 | ▶ | if ($path[$i] eq '@') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | 56 | $path[$i+1] = int($path[$i+1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | elsif ($path[$i] eq '/') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | 16 | my $keyname = $path[$i+1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | 16 | ▶ | (exists($keys{$keyname})) or die 'patternText2Dom() ! no key '.$keyname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | 16 | splice @path, $i, 2, @{ $keys{$keyname}{regexp} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | #warn "patternText2Dom(".join('',@pathTxt).')=> '.join(' ',@path)." ."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | #debug '=>'.join('.',@path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | 82 | return [@path]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | #{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | 27 | ▶ | sub textPatch2DOM(@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
textPatch2DOM: called CC=13 SCAR=26.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | =item I<textPatch2DOM>(<text patch 1>, <text patch 2> [,<text patch N>]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | convert a list of patches formatted in text (readable text format format) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | to a perl DOM format (man perldsc). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | Mainly used to convert the compare result (format dom) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | ARGS: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | a list of <patch in text format> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | Return a list of patches in dom mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | EX: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | C<textPatch2DOM>( 'change(@0$%a,@0$%a)="toto"/=>"tata"', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | 'move(... ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | returns ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | { action=>'change', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | path_orig=>['@0','$','%a'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | path_dest=>['@0','$','%a'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | val_orig=>"toto", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | val_dest=>"tata" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | { action=>'move', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | 27 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | 27 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | #}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | 27 | my $patch=pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | 27 | ▶ | defined($patch) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | 27 | debug "textPatch2DOM in ".$patch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | 27 | my ($p1,$p2,$v1,$v2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | 27 | ▶ | $patch =~ s/^(\w+)\(// or die 'Data::Deep::textPatch2DOM / bad patch format :'.$patch.' !!!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | 27 | my $action = $1; # or die 'action ???'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | 27 | ▶ | ( $patch =~ s/^([^,]*?),// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | ) and $p1 = patternText2Dom($1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | 27 | ▶ | ( $patch =~ s/^([^\(]*?)\)=// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | ) and $p2 = patternText2Dom($1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | 27 | ▶ | if ($action ne 'move') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | 27 | my $i = index($patch, '/=>'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | 27 | ▶ | if ($i ==-1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | 19 | ▶ | ($action eq 'add') && ($v2 = $patch) or ($v1 = $patch); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$action eq "add" and $v2 = $patch
MC/DC50%1/2
$action eq "add" and $v2 = $patch
$action eq "add"
$v2 = $patch
Truth table66%2/3
A and B
A= $action eq "add"B= $v2 = $patch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | 8 | $v1 = substr($patch, 0, $i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | 8 | $v2 = substr($patch, $i+3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | 27 | my $a = eval($v1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | 27 | ▶ | ($@) and die "textPatch2DOM() error in eval($v1) : ".$@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | 27 | my $b = eval($v2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | 27 | ▶ | ($@) and die "textPatch2DOM() error in eval($v2) : ".$@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | 27 | push @res,$patchDOM->($action, $p1, $p2, $a, $b); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | 27 | ▶ | (wantarray()) and return @res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | 0 | return [@res]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | =begin end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | Data::Deep was written by Matthieu Damerose I<E<lt>damo@cpan.orgE<gt>> in 2005. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | 1 | 1;############################################################################# | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | __END__ Deep::Manip.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||