line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Tokenize; |
2
|
3
|
|
|
3
|
|
64637
|
use warnings; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
81
|
|
3
|
3
|
|
|
3
|
|
12
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
94
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
6
|
3
|
|
|
3
|
|
314
|
use JSON::Parse; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
191
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ |
8
|
|
|
|
|
|
|
tokenize_child |
9
|
|
|
|
|
|
|
tokenize_end |
10
|
|
|
|
|
|
|
tokenize_json |
11
|
|
|
|
|
|
|
tokenize_next |
12
|
|
|
|
|
|
|
tokenize_start |
13
|
|
|
|
|
|
|
tokenize_text |
14
|
|
|
|
|
|
|
tokenize_type |
15
|
|
|
|
|
|
|
/; |
16
|
|
|
|
|
|
|
our %EXPORT_TAGS = ('all' => \@EXPORT_OK); |
17
|
3
|
|
|
3
|
|
22
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
508
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.62'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub tokenize_text |
21
|
|
|
|
|
|
|
{ |
22
|
4
|
|
|
4
|
1
|
9
|
my ($input, $token) = @_; |
23
|
4
|
50
|
33
|
|
|
20
|
if (! $input || ! $token) { |
24
|
0
|
|
|
|
|
0
|
croak "tokenize_text requires input string and JSON::Tokenize object"; |
25
|
|
|
|
|
|
|
} |
26
|
4
|
|
|
|
|
12
|
my $start = tokenize_start ($token); |
27
|
4
|
|
|
|
|
8
|
my $length = tokenize_end ($token) - $start; |
28
|
4
|
|
|
|
|
5
|
my $text; |
29
|
4
|
100
|
|
|
|
8
|
if (utf8::is_utf8 ($input)) { |
30
|
|
|
|
|
|
|
# $start and $length refer to bytes, so we need to convert |
31
|
|
|
|
|
|
|
# $input into bytes. |
32
|
1
|
|
|
|
|
2
|
my $copy = $input; |
33
|
1
|
|
|
|
|
2
|
utf8::encode ($copy); |
34
|
1
|
|
|
|
|
2
|
$text = substr ($copy, $start, $length); |
35
|
|
|
|
|
|
|
# Make the output utf8-flagged. |
36
|
1
|
|
|
|
|
7
|
utf8::decode ($text); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
3
|
|
|
|
|
6
|
$text = substr ($input, $start, $length); |
40
|
|
|
|
|
|
|
} |
41
|
4
|
|
|
|
|
13
|
return $text; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |