line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package XML::SAX::PurePerl::Reader::String; |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
150
|
use strict; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
451
|
|
6
|
12
|
|
|
12
|
|
60
|
use vars qw(@ISA); |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
568
|
|
7
|
|
|
|
|
|
|
|
8
|
12
|
|
|
|
|
909
|
use XML::SAX::PurePerl::Reader qw( |
9
|
|
|
|
|
|
|
LINE |
10
|
|
|
|
|
|
|
COLUMN |
11
|
|
|
|
|
|
|
BUFFER |
12
|
|
|
|
|
|
|
ENCODING |
13
|
|
|
|
|
|
|
EOF |
14
|
12
|
|
|
12
|
|
65
|
); |
|
12
|
|
|
|
|
27
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
@ISA = ('XML::SAX::PurePerl::Reader'); |
17
|
|
|
|
|
|
|
|
18
|
12
|
|
|
12
|
|
73
|
use constant DISCARDED => 8; |
|
12
|
|
|
|
|
29
|
|
|
12
|
|
|
|
|
656
|
|
19
|
12
|
|
|
12
|
|
62
|
use constant STRING => 9; |
|
12
|
|
|
|
|
27
|
|
|
12
|
|
|
|
|
521
|
|
20
|
12
|
|
|
12
|
|
60
|
use constant USED => 10; |
|
12
|
|
|
|
|
27
|
|
|
12
|
|
|
|
|
940
|
|
21
|
12
|
|
|
12
|
|
61
|
use constant CHUNK_SIZE => 2048; |
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
8121
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
3
|
|
|
3
|
0
|
9
|
my $class = shift; |
25
|
3
|
|
|
|
|
4
|
my $string = shift; |
26
|
3
|
|
|
|
|
7
|
my @parts; |
27
|
3
|
|
|
|
|
18
|
@parts[BUFFER, EOF, LINE, COLUMN, DISCARDED, STRING, USED] = |
28
|
|
|
|
|
|
|
('', 0, 1, 0, 0, $string, 0); |
29
|
3
|
|
|
|
|
16
|
return bless \@parts, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub read_more () { |
33
|
6
|
|
|
6
|
0
|
16
|
my $self = shift; |
34
|
6
|
100
|
|
|
|
26
|
if ($self->[USED] >= length($self->[STRING])) { |
35
|
3
|
|
|
|
|
6
|
$self->[EOF]++; |
36
|
3
|
|
|
|
|
8
|
return 0; |
37
|
|
|
|
|
|
|
} |
38
|
3
|
|
|
|
|
7
|
my $bytes = CHUNK_SIZE; |
39
|
3
|
50
|
|
|
|
17
|
if ($bytes > (length($self->[STRING]) - $self->[USED])) { |
40
|
3
|
|
|
|
|
8
|
$bytes = (length($self->[STRING]) - $self->[USED]); |
41
|
|
|
|
|
|
|
} |
42
|
3
|
|
|
|
|
17
|
$self->[BUFFER] .= substr($self->[STRING], $self->[USED], $bytes); |
43
|
3
|
|
|
|
|
6
|
$self->[USED] += $bytes; |
44
|
3
|
|
|
|
|
9
|
return 1; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub move_along { |
49
|
32
|
|
|
32
|
0
|
40
|
my($self, $bytes) = @_; |
50
|
32
|
|
|
|
|
100
|
my $discarded = substr($self->[BUFFER], 0, $bytes, ''); |
51
|
32
|
|
|
|
|
44
|
$self->[DISCARDED] += length($discarded); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Wish I could skip this lot - tells us where we are in the file |
54
|
32
|
|
|
|
|
40
|
my $lines = $discarded =~ tr/\n//; |
55
|
32
|
|
|
|
|
41
|
$self->[LINE] += $lines; |
56
|
32
|
50
|
|
|
|
56
|
if ($lines) { |
57
|
0
|
|
|
|
|
0
|
$discarded =~ /\n([^\n]*)$/; |
58
|
0
|
|
|
|
|
0
|
$self->[COLUMN] = length($1); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
32
|
|
|
|
|
77
|
$self->[COLUMN] += $_[0]; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub set_encoding { |
66
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
67
|
3
|
|
|
|
|
15
|
my ($encoding) = @_; |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
26
|
XML::SAX::PurePerl::Reader::switch_encoding_string($self->[BUFFER], $encoding, "utf-8"); |
70
|
3
|
|
|
|
|
786
|
$self->[ENCODING] = $encoding; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub bytepos { |
74
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
75
|
0
|
|
|
|
|
|
$self->[DISCARDED]; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |