blib/lib/dbgp-helper/DB/DbgrProperties.pm

filter: Statementstmt 0.0% 0 / 196 Branchbran 0.0% 0 / 110 Conditioncond 0.0% 0 / 45 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 399 CC 71 SCAR 63.1
CC
71
Cov
0%
_getFullPropertyInfoByValue
1260.0
_truncateIfNecessary
90.0
figureEncoding
72.0
CRAP 551.2
« blib/lib/dbgp-helper/DB/Data/Dump.pm ↑ Summary blib/lib/dbgp-helper/DB/DbgrContext.pm »
1 # DbgrProperties.pm -- Move all the property-handling code
2 # into this module.
3 #
4 # Copyright (c) 1998-2006 ActiveState Software Inc.
5 # All rights reserved.
6 #
7 # Xdebug compatibility, UNIX domain socket support and misc fixes
8 # by Mattia Barbon <mattia@barbon.org>
9 #
10 # This software (the Perl-DBGP package) is covered by the Artistic License
11 # (http://www.opensource.org/licenses/artistic-license.php).
12  
13 package DB::DbgrProperties;
14  
15 use strict qw(vars subs);
16  
17 our $VERSION = 0.10;
18 require Exporter;
19 our @ISA = qw(Exporter);
20 our @EXPORT = qw(
21 doPropertySetInfo
22 emitEvalResultAsProperty
23 emitEvaluatedPropertyGetInfo
24 figureEncoding
25 getFullPropertyInfoByValue
26 makeFullPropertyName
27 );
28 our @EXPORT_OK = ();
29  
30 use overload;
31  
32 use DB::Data::Dump;
33 use DB::DbgrCommon;
34  
35 # Internal sub declarations
36  
37 sub adjustLongName($$$);
38 sub makeFullPropertyName($$);
39  
40 # And recursively-called exported routines:
41  
42 sub figureEncoding($);
43 sub getFullPropertyInfoByValue($$$$$$);
44  
45 our $ldebug = 0;
46  
47 # Exported subs
48  
49 =head1 postconditions
50  
51 This function does one of three things:
52  
53 1. Throw an exception: let the caller deal with it, and formulate
54 an error message.
55  
56 2. Assign a value to a local value if it's a non-top-level stack
57 Return undef
58  
59 3. Return [$property_long_name, undef, 1]
60 and let the caller do an eval to carry out the assignment.
61  
62 =cut
63  
64 sub doPropertySetInfo($$$) {
65 0 ▶ my ($cmd,
Subroutine doPropertySetInfo: not called CC=2 SCAR=17.9
Pod undocumented
66 $transactionID,
67 $property_long_name) = @_;
68
69 0 ▶ if (!defined $property_long_name) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $property_long_name) { } 0 0 0
70 0 return makeErrorResponse($cmd,
71 $transactionID,
72 DBP_E_InvalidOption,
73 "-n full-property-name missing");
74 } else {
75 # In Perl these can be modified. Setting $_[x] to a value
76 # changes the underlying object if it isn't constant.
77 # Other changes will be ignored.
78 0 return [$property_long_name, undef, 1];
79 }
80 }
81  
82 sub emitEvaluatedPropertyGetInfo($$$$$$$) {
83 0 ▶ my ($cmd,
Subroutine emitEvaluatedPropertyGetInfo: not called CC=5 SCAR=34.0
Pod undocumented
84 $transactionID,
85 $nameAndValue,
86 $property_long_name, # For the response things.
87 $propertyKey,
88 $maxDataSize,
89 $pageIndex) = @_;
90  
91 0 my $res = sprintf(qq(%s\n<response %s command="%s"
92 transaction_id="%s" ),
93 xmlHeader(),
94 namespaceAttr(),
95 $cmd,
96 $transactionID);
97 0 my $finalName = $nameAndValue->[NV_NAME];
98 0 my $finalVal = $nameAndValue->[NV_VALUE];
99  
100 0 ▶ $res .= '>' if $cmd ne 'property_value';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd ne "property_value" 0 0 0
101 0 ▶ my $startTag = $cmd ne 'property_value' ? '<property' : '';
Branch: 1 branch
BranchTrueFalseTotal
$cmd ne 'property_value' ? : 0 0 0
102 0 ▶ my $endTag = $cmd ne 'property_value' ? '</property>' : '';
Branch: 1 branch
BranchTrueFalseTotal
$cmd ne 'property_value' ? : 0 0 0
103 0 ▶ $res .= _getFullPropertyInfoByValue($startTag, $endTag,
Condition0%0/3
$propertyKey || $finalName
l!l&&r!l&&!r
000
MC/DC0%0/2
$propertyKey || $finalName
$propertyKey $finalName
Truth table0%0/3
A || B
A= $propertyKeyB= $finalName
ABresult
1X1
011
000
104 $propertyKey || $finalName, # name
105 $finalName,
106 $finalVal,
107 $maxDataSize,
108 $pageIndex, # page
109 0, # current depth
110 );
111 0 $res .= "\n</response>";
112 0 printWithLength($res);
113 }
114  
115 sub _truncateIfNecessary {
116 0 ▶ my($res, $maxDataSize, $stripOuterBrackets) = @_;
Subroutine _truncateIfNecessary: not called CC=9 SCAR=45.0
117 0 ▶ if ($stripOuterBrackets && $res =~ /^([\[\{\(\<]).*([\]\}\)\>])$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stripOuterBrackets and $res =~ /^([\[\{\(\<]).*([\]\}\)\>])$/) 0 0 0
Condition0%0/3
$stripOuterBrackets and $res =~ /^([\[\{\(\<]).*([\]\}\)\>])$/
!ll&&!rl&&r
000
MC/DC0%0/2
$stripOuterBrackets and $res =~ /^([\[\{\(\<]).*([\]\}\)\>])$/
$stripOuterBrackets $res =~ /^([\[\{\(\<]).*([\]\}\)\>])$/
Truth table0%0/3
A and B
A= $stripOuterBracketsB= $res =~ /^([\[\{\(\<]).*([\]\}\)\>])$/
ABresult
0X0
100
111
118 0 substr($res, 0, 1) = "";
119 0 substr($res, -1, 1) = "";
120 }
121 # Truncate if exceeds size
122 0 ▶ if ($maxDataSize > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($maxDataSize > 0) 0 0 0
123 0 ▶ $maxDataSize -= 2 if $stripOuterBrackets;
Branch: 1 branch
BranchTrueFalseTotal
if $stripOuterBrackets 0 0 0
124 0 ▶ if (length($res) > $maxDataSize) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $res > $maxDataSize) 0 0 0
125 0 ▶ dblog("_truncateIfNecessary: Have length(\$res) = ", length($res), " > $maxDataSize") if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
126 0 ▶ if ($maxDataSize >= 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($maxDataSize >= 3) { } 0 0 0
127 0 $res = substr($res, 0, ($maxDataSize - 3)) . "...";
128 } else {
129 0 $res = substr($res, 0, $maxDataSize);
130 }
131 0 ▶ dblog("_truncateIfNecessary: After: length(\$res) = ", length($res)) if $ldebug;
Branch: 1 branch
BranchTrueFalseTotal
if $ldebug 0 0 0
132 }
133 }
134 0 return $res;
135 }
136  
137 sub emitEvalResultAsProperty($$$$$$) {
138 0 ▶ my ($cmd,
Subroutine emitEvalResultAsProperty: not called CC=1 SCAR=6.9
Pod undocumented
139 $transactionID,
140 $property_long_name,
141 $valRefs,
142 $maxDataSize,
143 $pageIndex) = @_;
144 0 my $res = sprintf(qq(%s\n<response %s command="%s"
145 transaction_id="%s" >),
146 xmlHeader(),
147 namespaceAttr(),
148 $cmd,
149 $transactionID);
150 0 $res .= getFullPropertyInfoByValue($property_long_name, # name
151 $property_long_name,
152 $valRefs,
153 $maxDataSize,
154 $pageIndex,
155 0, # current depth
156 );
157 0 $res .= "\n</response>";
158 0 printWithLength($res);
159 }
160  
161 sub propertyTagSpacer($) {
162 0 ▶ my ($currentDepth) = @_;
Subroutine propertyTagSpacer: not called CC=1 SCAR=6.9
Pod undocumented
163 0 return ("\n" . (' ' x $currentDepth));
164 }
165  
166 sub containsWideChar {
167 0 ▶ my ($str) = @_;
Subroutine containsWideChar: not called CC=4 SCAR=30.0
Pod undocumented
168 0 require bytes;
169 0 ▶ if (bytes::length($str) > length($str)
Branch: 1 branch
BranchTrueFalseTotal
if (&bytes::length($str) > length $str or $str =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/ or $str =~ /[^\0-\xff]/) 0 0 0
Condition0%0/6
&bytes::length($str) > length $str or $str =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/ or $str =~ /[^\0-\xff]/
l!l&&r!l&&!r
000
&bytes::length($str) > length $str or $str =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/
l!l&&r!l&&!r
000
MC/DC0%0/3
&bytes::length($str) > length $str or $str =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/ or $str =~ /[^\0-\xff]/
&bytes::length($str) > length $str $str =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/ $str =~ /[^\0-\xff]/
Truth table0%0/4
A or B or C
A= &bytes::length($str) > length $strB= $str =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/C= $str =~ /[^\0-\xff]/
ABCresult
1XX1
01X1
0011
0000
170 || $str =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/
171 || $str =~ /[^\0-\xff]/) {
172 0 return 1;
173 }
174 0 return 0;
175 }
176
177 sub figureEncoding($) {
178 0 ▶ my ($val) = @_;
Subroutine figureEncoding: not called CC=8 SCAR=42.8
Pod undocumented
179 0 my ($encVal);
180 0 my $encoding = $settings{data_encoding}->[0];
181 0 my $hasWide = containsWideChar($val);
182 0 ▶ if ($encoding eq 'none' || $encoding eq 'binary') {
Branch: 1 branch
BranchTrueFalseTotal
if ($encoding eq "none" or $encoding eq "binary") 0 0 0
Condition0%0/3
$encoding eq "none" or $encoding eq "binary"
l!l&&r!l&&!r
000
MC/DC0%0/2
$encoding eq "none" or $encoding eq "binary"
$encoding eq "none" $encoding eq "binary"
Truth table0%0/3
A or B
A= $encoding eq "none"B= $encoding eq "binary"
ABresult
1X1
011
000
183 0 ▶ if ($val =~ m/[\x00-\x08\x0b\x0c\x0e-\x1f]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ /[\x00-\x08\x0b\x0c\x0e-\x1f]/) 0 0 0
184 # Override
185 0 $encoding = 'base64';
186 }
187 }
188 0 ▶ if ($hasWide && $encoding eq 'base64') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hasWide and $encoding eq "base64") 0 0 0
Condition0%0/3
$hasWide and $encoding eq "base64"
!ll&&!rl&&r
000
MC/DC0%0/2
$hasWide and $encoding eq "base64"
$hasWide $encoding eq "base64"
Truth table0%0/3
A and B
A= $hasWideB= $encoding eq "base64"
ABresult
0X0
100
111
189 0 $val = nonXmlChar_Encode($val);
190 }
191 0 $encVal = encodeData($val, $encoding);
192 0 ▶ if ($encoding eq 'none' || $encoding eq 'binary') {
Branch: 1 branch
BranchTrueFalseTotal
if ($encoding eq "none" or $encoding eq "binary") 0 0 0
Condition0%0/3
$encoding eq "none" or $encoding eq "binary"
l!l&&r!l&&!r
000
MC/DC0%0/2
$encoding eq "none" or $encoding eq "binary"
$encoding eq "none" $encoding eq "binary"
Truth table0%0/3
A or B
A= $encoding eq "none"B= $encoding eq "binary"
ABresult
1X1
011
000
193 0 $encVal = xmlEncode($encVal);
194 }
195 0 return ($encoding, $encVal);
196 }
197  
198 sub _attr_needs_base64_encoding {
199 0 ▶ my ($val) = @_;
Subroutine _attr_needs_base64_encoding: not called CC=1 SCAR=6.9
200 0 return ($val =~ /[^\x20-\x7f]/);
201 }
202  
203 sub getFullPropertyInfoByValue($$$$$$) {
204 0 ▶ _getFullPropertyInfoByValue('<property', '</property>', @_);
Subroutine getFullPropertyInfoByValue: not called CC=1 SCAR=6.9
Pod undocumented
205 }
206  
207 sub _getFullPropertyInfoByValue {
208 0 ▶ my ($startTag,
Subroutine _getFullPropertyInfoByValue: not called CC=35 SCAR=71.4
209 $endTag,
210 $name,
211 $fullname,
212 $val,
213 $maxDataSize,
214 $pageIndex,
215 $currentDepth,
216 ) = @_;
217 0 require Scalar::Util;
218  
219 # dblog("getFullPropertyInfoByValue: (@_)\n");
220 0 my $encoding;
221 0 my $res = $startTag;
222 0 ▶ if ($currentDepth > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currentDepth > 0) 0 0 0
223 0 $res .= propertyTagSpacer($currentDepth);
224 }
225 0 my %b_attr = (name => $name, fullname => $fullname);
226 0 my %b_needs_attr;
227 0 $b_needs_attr{name} = _attr_needs_base64_encoding($name);
228 0 $b_needs_attr{fullname} = _attr_needs_base64_encoding($fullname);
229 0 ▶ while (my($k, $v) = each %b_needs_attr) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %b_needs_attr) 0 0 0
230 0 ▶ if (!$v) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v) 0 0 0
231 0 $res .= sprintf(qq( $k="%s"), xmlAttrEncode($b_attr{$k}));
232 0 delete $b_attr{$k};
233 }
234 }
235 0 my $typeString;
236 0 my $hasChildren = 0;
237 0 my $numChildren;
238 0 my $className;
239 0 my $encVal = undef;
240 0 my $encValLength = undef;
241 0 my $address;
242 0 my $hasValue = 1;
243 0 my $variableGroup = -1;
244 use constant VARIABLE_GROUP_ARRAY => 1;
245 use constant VARIABLE_GROUP_HASH => 2;
246 0 ▶ if (!defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $val) { } 0 0 0
247 0 $typeString = 'undef';
248 } else {
249 # Unlike getPropertyInfo, this is where we find
250 # arrays and hashes
251 0 ▶ if (my $reftype = Scalar::Util::reftype($val)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $reftype = &Scalar::Util::reftype($val)) { } 0 0 0
252 0 my $refstr = ref $val;
253 0 $className = Scalar::Util::blessed($val);
254 0 $address = Scalar::Util::refaddr($val);
255 0 ▶ $typeString = defined $className ? $className : $reftype;
Branch: 1 branch
BranchTrueFalseTotal
defined $className ? : 0 0 0
256 0 $hasValue = 0;
257 0 ▶ if ($reftype eq 'HASH') {
Branch: 3 branches
BranchTrueFalseTotal
if ($reftype eq 'HASH') { } 0 0 0
elsif ($reftype eq 'ARRAY') { } 0 0 0
elsif (defined $className or $reftype eq 'SCALAR' or $reftype eq 'REF') { } 0 0 0
258 0 $variableGroup = VARIABLE_GROUP_HASH;
259 0 $numChildren = keys %$val;
260 } elsif ($reftype eq 'ARRAY') {
261 0 $variableGroup = VARIABLE_GROUP_ARRAY;
262 0 $numChildren = @$val;
263 ▶ } elsif (defined $className || $reftype eq 'SCALAR' || $reftype eq 'REF') {
Condition0%0/6
defined $className or $reftype eq "SCALAR" or $reftype eq "REF"
l!l&&r!l&&!r
000
defined $className or $reftype eq "SCALAR"
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $className or $reftype eq "SCALAR" or $reftype eq "REF"
defined $className $reftype eq "SCALAR" $reftype eq "REF"
Truth table0%0/4
A or B or C
A= defined $classNameB= $reftype eq "SCALAR"C= $reftype eq "REF"
ABCresult
1XX1
01X1
0011
0000
264 # object but not array/hash: it's a scalar
265 0 $numChildren = 1;
266 }
267 0 ▶ if ($reftype eq 'REGEXP' || (
Branch: 1 branch
BranchTrueFalseTotal
if ($reftype eq "REGEXP" or $] < "5.012" and $reftype eq "SCALAR" and $className eq "Regexp" and _hasQrMagic($val)) 0 0 0
Condition0%0/12
$reftype eq "REGEXP" or $] < "5.012" and $reftype eq "SCALAR" and $className eq "Regexp" and _hasQrMagic($val)
l!l&&r!l&&!r
000
$] < "5.012" and $reftype eq "SCALAR" and $className eq "Regexp" and _hasQrMagic($val)
!ll&&!rl&&r
000
$] < "5.012" and $reftype eq "SCALAR" and $className eq "Regexp"
!ll&&!rl&&r
000
$] < "5.012" and $reftype eq "SCALAR"
!ll&&!rl&&r
000
MC/DC0%0/5
$reftype eq "REGEXP" or $] < "5.012" and $reftype eq "SCALAR" and $className eq "Regexp" and _hasQrMagic($val)
$reftype eq "REGEXP" $] < "5.012" $reftype eq "SCALAR" $className eq "Regexp" _hasQrMagic($val)
Truth table0%0/6
A or B and C and D and E
A= $reftype eq "REGEXP"B= $] < "5.012"C= $reftype eq "SCALAR"D= $className eq "Regexp"E= _hasQrMagic($val)
ABCDEresult
1XXXX1
011111
00XXX0
010XX0
0110X0
011100
268 $] < 5.012 &&
269 $reftype eq 'SCALAR' &&
270 $className eq 'Regexp' &&
271 _hasQrMagic($val))) {
272 # Special-case -- only one in Perl?
273 0 $val = substr("$val", 0, $maxDataSize);
274 0 ($encoding, $encVal) = figureEncoding($val);
275 0 $res .= sprintf(qq( encoding="%s"), $encoding);
276 0 $encValLength = length($encVal);
277 0 $numChildren = 0;
278 0 $hasValue = 1;
279 }
280 } else {
281 # It's a scalar -- get the underlying value and classify.
282 # First convert wide chars to utf-8
283 0 my $val2 = nonXmlChar_Encode($val);
284 0 my $val3 = _truncateIfNecessary($val2, $maxDataSize, 0);
285 0 ($encoding, $encVal) = figureEncoding($val3);
286 0 $res .= sprintf(qq( encoding="%s"), $encoding);
287 0 $encValLength = length($encVal);
288 0 $typeString = getCommonType($val2);
289 }
290 0 $hasChildren = !!$numChildren;
291 }
292 0 $res .= sprintf(qq( type="%s"), xmlAttrEncode($typeString));
293 0 $res .= qq( constant="0");
294 0 ▶ if ($hasChildren) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hasChildren) { } 0 0 0
295 0 $res .= qq( children="1" numchildren="$numChildren");
296 0 ▶ if (defined $address) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $address) 0 0 0
297 0 $res .= qq( address="$address");
298 }
299 } else {
300 0 $res .= qq( children="0");
301 }
302  
303 0 ▶ if ($hasChildren) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hasChildren) { } 0 0 0
304 0 $res .= qq( size="0");
305 0 $res .= qq( page="$pageIndex");
306 0 $res .= sprintf(qq( pagesize="%d"), $settings{max_children}[0]);
307 # Get each child property
308 0 ▶ if ($currentDepth < $settings{max_depth}[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($currentDepth < $DB::DbgrProperties::settings{'max_depth'}[0]) { } 0 0 0
309 0 my $childrenPerPage = $settings{max_children}[0];
310 0 my $startIndex = $pageIndex * $childrenPerPage;
311 0 my $endIndex = $startIndex + $childrenPerPage - 1;
312 0 ▶ if ($variableGroup == VARIABLE_GROUP_ARRAY) {
Branch: 2 branches
BranchTrueFalseTotal
if ($variableGroup == 1) { } 0 0 0
elsif ($variableGroup == 2) { } 0 0 0
313 0 my $arraySize = scalar @$val;
314 #### ???? $res .= sprintf(qq( numchildren="%d"), $arraySize);
315 0 $res .= qq(>);
316 0 $res .= _getFullPropertyInfoByValue_emitNames($maxDataSize, %b_attr);
317 0 ▶ if ($startIndex < $arraySize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($startIndex < $arraySize) 0 0 0
318 0 ▶ if ($endIndex >= $arraySize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($endIndex >= $arraySize) 0 0 0
319 0 $endIndex = $arraySize - 1;
320 }
321 0 ▶ for (my $i = $startIndex; $i <= $endIndex; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $endIndex) 0 0 0
322 0 my ($newInnerName, $newFullName) =
323 adjustLongName($fullname, $i, 1);
324 0 my $innerProp =
325 getFullPropertyInfoByValue($newInnerName,
326 $newFullName,
327 $val->[$i],
328 $maxDataSize,
329 # For inner children,
330 # show first page
331 0,
332 $currentDepth + 1);
333 0 $res .= "$innerProp";
334 }
335 }
336 } elsif ($variableGroup == VARIABLE_GROUP_HASH) {
337 0 my @keys = sort keys %$val;
338 0 my $arraySize = scalar @keys;
339 #### ???? $res .= sprintf(qq( numchildren="%d"), $arraySize);
340 0 $res .= qq(>);
341 0 $res .= _getFullPropertyInfoByValue_emitNames($maxDataSize, %b_attr);
342 0 ▶ if ($startIndex < $arraySize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($startIndex < $arraySize) 0 0 0
343 0 ▶ if ($endIndex >= $arraySize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($endIndex >= $arraySize) 0 0 0
344 0 $endIndex = $arraySize - 1;
345 }
346 0 ▶ for (my $i = $startIndex; $i <= $endIndex; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $endIndex) 0 0 0
347 0 my $k = $keys[$i];
348 0 my ($newInnerName, $newFullName) =
349 adjustLongName($fullname, $k, 0);
350 my $innerProp =
351 getFullPropertyInfoByValue($newInnerName,
352 $newFullName,
353 0 $val->{$k},
354 $maxDataSize,
355 # For inner children,
356 # show first page
357 0,
358 $currentDepth + 1);
359 0 $res .= "$innerProp";
360 }
361 }
362 } else {
363 # Objects just have one child
364 #### $res .= qq( numchildren="1");
365 0 $res .= qq(>);
366 0 $res .= _getFullPropertyInfoByValue_emitNames($maxDataSize, %b_attr);
367 0 my $innerProp =
368 getFullPropertyInfoByValue("->",
369 "\${$fullname}",
370 $$val,
371 $maxDataSize,
372 # For inner children,
373 # show first page
374 0,
375 $currentDepth + 1);
376 0 $res .= "$innerProp";
377 }
378 } else {
379 # End the start-tag.
380 0 $res .= qq( >);
381 0 $res .= _getFullPropertyInfoByValue_emitNames($maxDataSize, %b_attr);
382 }
383 0 $res .= $endTag . qq(\n);
384 } else {
385 0 ▶ $res .= qq( size="$encValLength") if defined $encValLength;
Branch: 1 branch
BranchTrueFalseTotal
if defined $encValLength 0 0 0
386 0 $res .= qq( >);
387 0 $res .= _getFullPropertyInfoByValue_emitNames($maxDataSize, %b_attr);
388 0 ▶ if (!$hasValue || !defined($encVal)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $hasValue && defined $encVal) { } 0 0 0
elsif ($DB::xdebug_no_value_tag) { } 0 0 0
Condition0%0/3
$hasValue && defined $encVal
!ll&&!rl&&r
000
MC/DC0%0/2
$hasValue && defined $encVal
$hasValue defined $encVal
Truth table0%0/3
A && B
A= $hasValueB= defined $encVal
ABresult
0X0
100
111
389 # Do nothing
390 } elsif ($DB::xdebug_no_value_tag) {
391 0 $res .= $encVal;
392 } else {
393 0 ▶ $res .= sprintf(qq(<value%s><![CDATA[%s]]></value>\n),
Branch: 1 branch
BranchTrueFalseTotal
$encoding ? : 0 0 0
394 $encoding ? qq( encoding="$encoding") : "",
395 $encVal);
396 }
397 0 $res .= $endTag;
398 0 ▶ $res .= "\n" if $currentDepth == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $currentDepth == 0 0 0 0
399 }
400 # dblog("getFullPropertyInfoByValue: \{$res}\n");
401 0 return $res;
402 }
403  
404 sub _hasQrMagic {
405 0 ▶ my ($val) = @_;
Subroutine _hasQrMagic: not called CC=4 SCAR=30.0
406  
407 0 require B;
408  
409 0 my $b = B::svref_2object($val);
410  
411 0 ▶ return unless $b->isa('B::PVMG');
Branch: 1 branch
BranchTrueFalseTotal
unless $b->isa("B::PVMG") 0 0 0
412 0 ▶ for (my $m = $b->MAGIC; $m; $m = $m->MOREMAGIC) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m) 0 0 0
413 0 ▶ return 1 if $m->TYPE eq 'r';
Branch: 1 branch
BranchTrueFalseTotal
if $m->TYPE eq "r" 0 0 0
414 }
415  
416 0 return 0;
417 }
418  
419 sub _getFullPropertyInfoByValue_emitNames {
420 0 ▶ my ($maxDataSize, %b_attr) = @_;
Subroutine _getFullPropertyInfoByValue_emitNames: not called CC=2 SCAR=17.9
421 0 my $ret = "";
422 0 ▶ while (my ($k, $v) = each %b_attr) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %b_attr) 0 0 0
423 0 my $val2 = nonXmlChar_Encode($v);
424 0 my $val3 = _truncateIfNecessary($val2, $maxDataSize, 0);
425 0 $ret .= (qq(<$k encoding="base64">)
426 . xmlAttrEncode(encodeData($val3, 'base64'))
427 . "</$k>\n");
428 }
429 0 return $ret;
430 }
431  
432 #############################################################################
433  
434 # Internal subs
435  
436 sub adjustLongName($$$) {
437 0 ▶ my ($fullname, $key, $isArray) = @_;
Subroutine adjustLongName: not called CC=7 SCAR=40.3
Pod undocumented
438 0 ▶ if ($isArray) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isArray) { } 0 0 0
439 0 ▶ if ($fullname =~ m/^(\@)(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fullname =~ /^(\@)(.*)/) { } 0 0 0
440 0 return ("[$key]", sprintf('$%s[%d]', $2, $key));
441 } else {
442 0 return ("->[$key]", "${fullname}->[$key]");
443 }
444 } else {
445 # Don't use Data::Dump for hash keys, as it's doing too
446 # much processing on hash keys.
447 # Data::Dump was used to fix bugs 79892, 79894, and 79895 in r22847.
448 # However Data::Dump \x-encodes high-bit characters,
449 # which makes them hard to read in the UI, so we need to do
450 # our own encoding.
451 # This change fixes bug 83959
452 0 ▶ if ($key =~ /^-?[a-zA-Z_]\w*$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($key =~ /^-?[a-zA-Z_]\w*$/) { } 0 0 0
elsif ($key =~ /^-?[1-9]\d{0,8}$/ or $key eq '0') { } 0 0 0
453 # Don't quote barewords
454 ▶ } elsif ($key =~ /^-?[1-9]\d{0,8}$/ || $key eq "0") {
Condition0%0/3
$key =~ /^-?[1-9]\d{0,8}$/ or $key eq 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$key =~ /^-?[1-9]\d{0,8}$/ or $key eq 0
$key =~ /^-?[1-9]\d{0,8}$/ $key eq 0
Truth table0%0/3
A or B
A= $key =~ /^-?[1-9]\d{0,8}$/B= $key eq 0
ABresult
1X1
011
000
455 # Don't quote integers
456 } else {
457 # Convert low-byte values, leave high-byte values alone,
458 # and backslash-escape the usual suspects.
459 0 $key =~ s{([\\\"\$\@\*\%])}
460 {\\$1}g;
461 0 $key =~ s{([\x00-\x08\x0b\x0c\x0e-\x1f])}
462 0 {sprintf('\\x%02x', hex(ord($1)))}egx;
463 0 $key =~ s{\t}{\\t}gx;
464 0 $key =~ s{\r}{\\r}gx;
465 0 $key =~ s{\n}{\\n}gx;
466 0 $key = '"' . $key . '"';
467 }
468 0 ▶ if ($fullname =~ m/^(\%)(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fullname =~ /^(\%)(.*)/) { } 0 0 0
469 # Verify that single-quotes won't nest.
470 0 return ("{$key}", sprintf(q($%s{%s}), $2, $key));
471 } else {
472 0 return ("->{$key}", "${fullname}->{$key}");
473 }
474 }
475 }
476  
477 sub makeFullPropertyName($$) {
478 0 ▶ my ($property_long_name, $propertyKey) = @_;
Subroutine makeFullPropertyName: not called CC=4 SCAR=30.0
Pod undocumented
479 0 ▶ if (!$propertyKey) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $propertyKey) { } 0 0 0
elsif ($property_long_name =~ /^[\@\%](.*)/) { } 0 0 0
elsif ($propertyKey =~ /^->/) { } 0 0 0
480 0 return ($property_long_name, undef);
481 } elsif ($property_long_name =~ /^[\@\%](.*)/) {
482 0 return (sprintf(q($%s%s), $1, $propertyKey), $propertyKey);
483 } elsif ($propertyKey =~ /^->/) {
484 0 return (sprintf(q(%s%s), $property_long_name, $propertyKey), $propertyKey);
485 } else {
486 0 return (sprintf(q(%s->%s), $property_long_name, $propertyKey), "->$propertyKey");
487 }
488 }
489  
490 1;
« blib/lib/dbgp-helper/DB/Data/Dump.pm ↑ Summary blib/lib/dbgp-helper/DB/DbgrContext.pm »