line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Tokenize; |
2
|
2
|
|
|
2
|
|
13430
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
3
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
66
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
6
|
2
|
|
|
2
|
|
8
|
use JSON::Parse; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
117
|
|
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
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
377
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.61'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub tokenize_text |
21
|
|
|
|
|
|
|
{ |
22
|
4
|
|
|
4
|
1
|
8
|
my ($input, $token) = @_; |
23
|
4
|
50
|
33
|
|
|
27
|
if (! $input || ! $token) { |
24
|
0
|
|
|
|
|
0
|
croak "tokenize_text requires input string and JSON::Tokenize object"; |
25
|
|
|
|
|
|
|
} |
26
|
4
|
|
|
|
|
15
|
my $start = tokenize_start ($token); |
27
|
4
|
|
|
|
|
9
|
my $length = tokenize_end ($token) - $start; |
28
|
4
|
|
|
|
|
4
|
my $text; |
29
|
4
|
100
|
|
|
|
10
|
if (utf8::is_utf8 ($input)) { |
30
|
|
|
|
|
|
|
# $start and $length refer to bytes, so we need to convert |
31
|
|
|
|
|
|
|
# $input into bytes. |
32
|
1
|
|
|
|
|
3
|
my $copy = $input; |
33
|
1
|
|
|
|
|
4
|
utf8::encode ($copy); |
34
|
1
|
|
|
|
|
3
|
$text = substr ($copy, $start, $length); |
35
|
|
|
|
|
|
|
# Make the output utf8-flagged. |
36
|
1
|
|
|
|
|
7
|
utf8::decode ($text); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
3
|
|
|
|
|
7
|
$text = substr ($input, $start, $length); |
40
|
|
|
|
|
|
|
} |
41
|
4
|
|
|
|
|
14
|
return $text; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |