| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Vcdiff::OpenVcdiff; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
35172
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
80
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
183
|
|
|
6
|
2
|
|
|
2
|
|
1858
|
use Guard; |
|
|
2
|
|
|
|
|
1368
|
|
|
|
2
|
|
|
|
|
108
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
779
|
use Vcdiff; |
|
|
2
|
|
|
|
|
8996
|
|
|
|
2
|
|
|
|
|
2082
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.106'; |
|
11
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require XSLoader; |
|
14
|
|
|
|
|
|
|
XSLoader::load('Vcdiff::OpenVcdiff', $VERSION); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub diff { |
|
19
|
65
|
|
|
65
|
0
|
126942
|
my ($source, $input, $output) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
65
|
|
|
|
|
116
|
my ($source_str, $input_fileno, $input_str, $output_fileno, $output_str); |
|
22
|
0
|
|
|
|
|
0
|
my $source_str_guard; |
|
23
|
|
|
|
|
|
|
|
|
24
|
65
|
|
|
|
|
149
|
$input_fileno = $output_fileno = -1; |
|
25
|
|
|
|
|
|
|
|
|
26
|
65
|
50
|
|
|
|
224
|
if (!defined $source) { |
|
|
|
100
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
croak "diff needs source argument"; |
|
28
|
|
|
|
|
|
|
} elsif (ref $source eq 'GLOB') { |
|
29
|
33
|
|
|
|
|
2369
|
require Sys::Mmap; |
|
30
|
|
|
|
|
|
|
|
|
31
|
33
|
50
|
|
|
|
3437
|
if (!defined Sys::Mmap::mmap($source_str, 0, Sys::Mmap::PROT_READ(), Sys::Mmap::MAP_SHARED(), $source)) { |
|
32
|
0
|
|
|
|
|
0
|
croak "unable to mmap filehandle (maybe it's a pipe or socket instead of a file): $!"; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$source_str_guard = guard { |
|
36
|
32
|
50
|
|
32
|
|
732
|
Sys::Mmap::munmap($source_str) || carp "failed to munmap: $!"; |
|
37
|
32
|
|
|
|
|
1693
|
}; |
|
38
|
|
|
|
|
|
|
} else { |
|
39
|
32
|
|
|
|
|
45
|
$source_str = $source; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
64
|
50
|
|
|
|
199
|
if (!defined $input) { |
|
|
|
100
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
croak "diff needs target argument"; |
|
44
|
|
|
|
|
|
|
} elsif (ref $input eq 'GLOB') { |
|
45
|
32
|
|
|
|
|
60
|
$input_fileno = fileno($input); |
|
46
|
32
|
50
|
33
|
|
|
196
|
croak "target file handle is closed or invalid" if !defined $input_fileno || $input_fileno == -1; |
|
47
|
|
|
|
|
|
|
} else { |
|
48
|
32
|
|
|
|
|
51
|
$input_str = $input; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
64
|
100
|
|
|
|
123
|
if (defined $output) { |
|
52
|
32
|
50
|
|
|
|
96
|
croak "output argument to diff should be a file handle or undef" |
|
53
|
|
|
|
|
|
|
if ref $output ne 'GLOB'; |
|
54
|
|
|
|
|
|
|
|
|
55
|
32
|
|
|
|
|
56
|
$output_fileno = fileno($output); |
|
56
|
32
|
50
|
33
|
|
|
157
|
croak "output file handle is closed or invalid" if !defined $output_fileno || $output_fileno == -1; |
|
57
|
|
|
|
|
|
|
} else { |
|
58
|
32
|
|
|
|
|
43
|
$output_str = ''; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
64
|
|
|
|
|
104933
|
my $ret = _encode($source_str, $input_fileno, $input_str, $output_fileno, $output_str); |
|
62
|
|
|
|
|
|
|
|
|
63
|
64
|
|
|
|
|
190
|
_check_ret($ret, 'diff'); |
|
64
|
|
|
|
|
|
|
|
|
65
|
64
|
100
|
|
|
|
591
|
return $output_str if !defined $output; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub patch { |
|
72
|
64
|
|
|
64
|
0
|
6029
|
my ($source, $input, $output) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
64
|
|
|
|
|
94
|
my ($source_str, $input_fileno, $input_str, $output_fileno, $output_str); |
|
75
|
0
|
|
|
|
|
0
|
my $source_str_guard; |
|
76
|
|
|
|
|
|
|
|
|
77
|
64
|
|
|
|
|
91
|
$input_fileno = $output_fileno = -1; |
|
78
|
|
|
|
|
|
|
|
|
79
|
64
|
50
|
|
|
|
210
|
if (!defined $source) { |
|
|
|
100
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
croak "patch needs source argument"; |
|
81
|
|
|
|
|
|
|
} elsif (ref $source eq 'GLOB') { |
|
82
|
32
|
|
|
|
|
149
|
require Sys::Mmap; |
|
83
|
|
|
|
|
|
|
|
|
84
|
32
|
50
|
|
|
|
107
|
if (!defined Sys::Mmap::mmap($source_str, 0, Sys::Mmap::PROT_READ(), Sys::Mmap::MAP_SHARED(), $source)) { |
|
85
|
0
|
|
|
|
|
0
|
croak "unable to mmap filehandle (maybe it's a pipe or socket instead of a file): $!"; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$source_str_guard = guard { |
|
89
|
32
|
50
|
|
32
|
|
459
|
Sys::Mmap::munmap($source_str) || carp "failed to munmap: $!"; |
|
90
|
32
|
|
|
|
|
886
|
}; |
|
91
|
|
|
|
|
|
|
} else { |
|
92
|
32
|
|
|
|
|
46
|
$source_str = $source; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
64
|
50
|
|
|
|
189
|
if (!defined $input) { |
|
|
|
100
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
0
|
croak "patch needs delta argument"; |
|
97
|
|
|
|
|
|
|
} elsif (ref $input eq 'GLOB') { |
|
98
|
32
|
|
|
|
|
78
|
$input_fileno = fileno($input); |
|
99
|
32
|
50
|
33
|
|
|
170
|
croak "delta file handle is closed or invalid" if !defined $input_fileno || $input_fileno == -1; |
|
100
|
|
|
|
|
|
|
} else { |
|
101
|
32
|
|
|
|
|
54
|
$input_str = $input; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
64
|
100
|
|
|
|
109
|
if (defined $output) { |
|
105
|
32
|
50
|
|
|
|
75
|
croak "output argument to patch should be a file handle or undef" |
|
106
|
|
|
|
|
|
|
if ref $output ne 'GLOB'; |
|
107
|
|
|
|
|
|
|
|
|
108
|
32
|
|
|
|
|
50
|
$output_fileno = fileno($output); |
|
109
|
32
|
50
|
33
|
|
|
137
|
croak "output file handle is closed or invalid" if !defined $output_fileno || $output_fileno == -1; |
|
110
|
|
|
|
|
|
|
} else { |
|
111
|
32
|
|
|
|
|
55
|
$output_str = ''; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
64
|
|
|
|
|
25308
|
my $ret = _decode($source_str, $input_fileno, $input_str, $output_fileno, $output_str); |
|
115
|
|
|
|
|
|
|
|
|
116
|
64
|
|
|
|
|
152
|
_check_ret($ret, 'patch'); |
|
117
|
|
|
|
|
|
|
|
|
118
|
64
|
100
|
|
|
|
356
|
return $output_str if !defined $output; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $exception_map = { |
|
126
|
|
|
|
|
|
|
1 => 'unable to initialize HashedDictionary', |
|
127
|
|
|
|
|
|
|
2 => 'StartEncoding error', |
|
128
|
|
|
|
|
|
|
3 => 'error reading from target/delta', |
|
129
|
|
|
|
|
|
|
4 => 'EncodeChunk error', |
|
130
|
|
|
|
|
|
|
5 => 'error writing to output', |
|
131
|
|
|
|
|
|
|
6 => 'FinishEncoding error', |
|
132
|
|
|
|
|
|
|
7 => 'DecodeChunk error', |
|
133
|
|
|
|
|
|
|
8 => 'FinishDecoding error', |
|
134
|
|
|
|
|
|
|
9 => 'unknown C++ exception', |
|
135
|
|
|
|
|
|
|
}; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub _check_ret { |
|
138
|
128
|
|
|
128
|
|
207
|
my ($ret, $func) = @_; |
|
139
|
|
|
|
|
|
|
|
|
140
|
128
|
50
|
|
|
|
376
|
return unless $ret; |
|
141
|
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
my $exception = $exception_map->{$ret}; |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
croak "error in Vcdiff::OpenVcdiff::$func: $exception" if $exception; |
|
145
|
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
croak "unknown error in Vcdiff::OpenVcdiff::$func ($ret)"; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |