line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Diff3::Text; |
2
|
6
|
|
|
6
|
|
100
|
use 5.006; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
225
|
|
3
|
6
|
|
|
6
|
|
28
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
178
|
|
4
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
177
|
|
5
|
6
|
|
|
6
|
|
33
|
use base qw(Text::Diff3::ListMixin Text::Diff3::Base); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
791
|
use version; our $VERSION = '0.08'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
22
|
|
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
1
|
0
|
sub text { return $_[0]->{text} } |
10
|
1
|
|
|
1
|
1
|
6
|
sub list { return $_[0]->{text} } # interface to ListMixin |
11
|
|
|
|
|
|
|
|
12
|
1704
|
|
|
1704
|
1
|
10291
|
sub first_index { return 1 } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub last_index { |
15
|
291
|
|
|
291
|
1
|
300
|
my($self) = @_; |
16
|
291
|
|
|
|
|
279
|
return $#{$self->{text}} + $self->first_index; |
|
291
|
|
|
|
|
601
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub range { |
20
|
97
|
|
|
97
|
1
|
105
|
my($self) = @_; |
21
|
97
|
|
|
|
|
161
|
return ($self->first_index .. $self->last_index); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub at { |
25
|
1119
|
|
|
1119
|
1
|
2460
|
my($self, $x) = @_; |
26
|
1119
|
|
|
|
|
1640
|
$x -= $self->first_index; |
27
|
1119
|
100
|
66
|
|
|
2274
|
return $x < 0 || $x > $#{$self->{text}} ? undef : $self->{text}[$x]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub as_string_range { |
31
|
0
|
|
|
0
|
1
|
0
|
my($self, @range) = @_; |
32
|
0
|
|
|
|
|
0
|
my $t = q{}; |
33
|
0
|
|
|
|
|
0
|
for (@range) { |
34
|
0
|
|
|
|
|
0
|
my $line = $self->at($_); |
35
|
0
|
0
|
|
|
|
0
|
if (defined $line) { |
36
|
0
|
|
|
|
|
0
|
$t .= $line . "\n"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
0
|
return $t; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub as_string_at { |
43
|
0
|
|
|
0
|
1
|
0
|
my($self, $x) = @_; |
44
|
0
|
|
|
|
|
0
|
my $line = $self->at($x); |
45
|
0
|
0
|
|
|
|
0
|
return defined($line) ? $line . "\n" : q{}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub eq_at { |
49
|
262
|
|
|
262
|
1
|
339
|
my($self, $x, $other) = @_; |
50
|
262
|
|
|
|
|
413
|
my $this = $self->at($x); |
51
|
262
|
100
|
|
|
|
606
|
return 0 if (defined $this) ^ (defined $other); |
52
|
260
|
|
100
|
|
|
1668
|
return ! (defined $this) || $this eq $other; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub initialize { |
56
|
77
|
|
|
77
|
1
|
134
|
my($self, @arg) = @_; |
57
|
77
|
|
|
|
|
249
|
$self->SUPER::initialize(@arg); |
58
|
77
|
|
|
|
|
113
|
my($f, $s) = @arg; |
59
|
77
|
100
|
|
|
|
156
|
if (ref $s eq 'ARRAY') { |
60
|
76
|
|
|
|
|
119
|
$self->{text} = $s; |
61
|
|
|
|
|
|
|
} else { |
62
|
1
|
50
|
|
|
|
6
|
if (ref $s) { |
63
|
0
|
|
|
|
|
0
|
$s = ${$s}; |
|
0
|
|
|
|
|
0
|
|
64
|
|
|
|
|
|
|
} |
65
|
1
|
|
|
|
|
4
|
chomp $s; |
66
|
1
|
|
|
|
|
5
|
$self->{text} = [split /\n/msx, $s, -1]; |
67
|
|
|
|
|
|
|
} |
68
|
77
|
|
|
|
|
162
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |