line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::XPath::Helper::String;
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
205973
|
use 5.008;
|
|
3
|
|
|
|
|
33
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
99
|
|
5
|
3
|
|
|
3
|
|
16
|
use warnings;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
120
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
27
|
use Exporter 'import';
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
251
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.02';
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(quoted_string one_of_quoted not_one_of_quoted);
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => \@EXPORT_OK);
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
22
|
use Carp;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2038
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub quoted_string {
|
20
|
15
|
100
|
|
15
|
1
|
2041
|
@_ == 1 or croak("Wrong number of arguments");
|
21
|
14
|
|
|
|
|
32
|
my $arg = shift;
|
22
|
14
|
|
|
|
|
18
|
my $arg_scalar;
|
23
|
14
|
100
|
|
|
|
36
|
if (ref($arg)) {
|
24
|
10
|
100
|
|
|
|
197
|
croak("Argument must be a string or a reference to an array") unless ref($arg) eq 'ARRAY';
|
25
|
|
|
|
|
|
|
} else {
|
26
|
4
|
|
|
|
|
7
|
$arg_scalar = 1;
|
27
|
4
|
100
|
|
|
|
11
|
$arg = "" if !defined($arg);
|
28
|
4
|
|
|
|
|
8
|
$arg = [$arg];
|
29
|
|
|
|
|
|
|
}
|
30
|
13
|
|
|
|
|
26
|
my @result;
|
31
|
13
|
|
|
|
|
16
|
foreach my $string (@{$arg}) {
|
|
13
|
|
|
|
|
30
|
|
32
|
21
|
100
|
|
|
|
58
|
if (index($string, "'") >= 0) {
|
33
|
10
|
|
|
|
|
19
|
my @array;
|
34
|
10
|
|
|
|
|
54
|
foreach my $substr (grep{length($_)} split(/('+)/, $string)) {
|
|
37
|
|
|
|
|
63
|
|
35
|
32
|
100
|
|
|
|
69
|
my $q = substr($substr, 0, 1) eq "'" ? '"' : "'";
|
36
|
32
|
|
|
|
|
73
|
push(@array, "${q}${substr}${q}");
|
37
|
|
|
|
|
|
|
}
|
38
|
10
|
|
|
|
|
41
|
push(@result, 'concat(' . join(',', @array) . ')');
|
39
|
|
|
|
|
|
|
} else {
|
40
|
11
|
|
|
|
|
33
|
push(@result, "'$string'");
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
}
|
43
|
13
|
100
|
|
|
|
80
|
return ($arg_scalar ? $result[0] : \@result);
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub one_of_quoted {
|
48
|
3
|
50
|
|
3
|
1
|
94
|
@_ > 0 or croak("Too few arguments");
|
49
|
3
|
|
|
|
|
10
|
my ($array, $name) = @_;
|
50
|
3
|
50
|
|
|
|
9
|
ref($array) eq 'ARRAY' or croak("Argument 1 must be an ARRAY ref");
|
51
|
3
|
100
|
|
|
|
10
|
if (defined($name)) {
|
52
|
2
|
50
|
|
|
|
5
|
ref($name) and croak("Argument 2 must be a scalar");
|
53
|
2
|
|
|
|
|
7
|
return "$name=" . join(" or $name=", @{quoted_string($array)});
|
|
2
|
|
|
|
|
5
|
|
54
|
|
|
|
|
|
|
} else {
|
55
|
1
|
|
|
|
|
3
|
my $values = quoted_string($array);
|
56
|
1
|
|
|
2
|
|
7
|
return sub { return "$_[0]=" . join(" or $_[0]=", @{$values}); };
|
|
2
|
|
|
|
|
443
|
|
|
2
|
|
|
|
|
12
|
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub not_one_of_quoted {
|
62
|
3
|
50
|
|
3
|
1
|
524
|
@_ > 0 or croak("Too few arguments");
|
63
|
3
|
|
|
|
|
8
|
my ($array, $name) = @_;
|
64
|
3
|
50
|
|
|
|
10
|
ref($array) eq 'ARRAY' or croak("Argument 1 must be an ARRAY ref");
|
65
|
3
|
100
|
|
|
|
10
|
if (defined($name)) {
|
66
|
2
|
50
|
|
|
|
5
|
ref($name) and croak("Argument 2 must be a scalar");
|
67
|
2
|
|
|
|
|
6
|
return "$name!=" . join(" and $name!=", @{quoted_string($array)});
|
|
2
|
|
|
|
|
5
|
|
68
|
|
|
|
|
|
|
} else {
|
69
|
1
|
|
|
|
|
4
|
my $values = quoted_string($array);
|
70
|
1
|
|
|
1
|
|
7
|
return sub { return "$_[0]!=" . join(" and $_[0]!=", @{$values}); };
|
|
1
|
|
|
|
|
352
|
|
|
1
|
|
|
|
|
6
|
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; # End of XML::XPath::Helper::String
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__
|