line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Tokenize; |
2
|
3
|
|
|
3
|
|
69692
|
use warnings; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
77
|
|
3
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
92
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
6
|
3
|
|
|
3
|
|
351
|
use JSON::Parse; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
209
|
|
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
|
|
35
|
use Carp; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
584
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.61_01'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub tokenize_text |
21
|
|
|
|
|
|
|
{ |
22
|
4
|
|
|
4
|
1
|
20
|
my ($input, $token) = @_; |
23
|
4
|
50
|
33
|
|
|
25
|
if (! $input || ! $token) { |
24
|
0
|
|
|
|
|
0
|
croak "tokenize_text requires input string and JSON::Tokenize object"; |
25
|
|
|
|
|
|
|
} |
26
|
4
|
|
|
|
|
14
|
my $start = tokenize_start ($token); |
27
|
4
|
|
|
|
|
10
|
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
|
|
|
|
|
2
|
my $copy = $input; |
33
|
1
|
|
|
|
|
3
|
utf8::encode ($copy); |
34
|
1
|
|
|
|
|
2
|
$text = substr ($copy, $start, $length); |
35
|
|
|
|
|
|
|
# Make the output utf8-flagged. |
36
|
1
|
|
|
|
|
8
|
utf8::decode ($text); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
3
|
|
|
|
|
7
|
$text = substr ($input, $start, $length); |
40
|
|
|
|
|
|
|
} |
41
|
4
|
|
|
|
|
14
|
return $text; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |