Filename | /usr/lib/perl/5.10/IO/Uncompress/Gunzip.pm |
Statements | Executed 38 statements in 1.98ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.61ms | 13.9ms | BEGIN@12 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 23µs | 211µs | BEGIN@50 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 21µs | 55µs | BEGIN@9 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 19µs | 24µs | BEGIN@8 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 19µs | 384µs | BEGIN@16 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 16µs | 68µs | BEGIN@14 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 15µs | 178µs | BEGIN@15 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 15µs | 30µs | BEGIN@17 | IO::Uncompress::Gunzip::
1 | 1 | 1 | 13µs | 17µs | BEGIN@10 | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | _readFullGzipHeader | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | _readGzipHeader | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | chkTrailer | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | ckMagic | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | ckParams | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | getExtraParams | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | gunzip | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | isGzipMagic | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | new | IO::Uncompress::Gunzip::
0 | 0 | 0 | 0s | 0s | readHeader | IO::Uncompress::Gunzip::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package IO::Uncompress::Gunzip ; | ||||
3 | |||||
4 | 1 | 20µs | require 5.004 ; | ||
5 | |||||
6 | # for RFC1952 | ||||
7 | |||||
8 | 3 | 46µs | 2 | 29µs | # spent 24µs (19+5) within IO::Uncompress::Gunzip::BEGIN@8 which was called:
# once (19µs+5µs) by Compress::Zlib::BEGIN@14 at line 8 # spent 24µs making 1 call to IO::Uncompress::Gunzip::BEGIN@8
# spent 5µs making 1 call to strict::import |
9 | 3 | 52µs | 2 | 89µs | # spent 55µs (21+34) within IO::Uncompress::Gunzip::BEGIN@9 which was called:
# once (21µs+34µs) by Compress::Zlib::BEGIN@14 at line 9 # spent 55µs making 1 call to IO::Uncompress::Gunzip::BEGIN@9
# spent 34µs making 1 call to warnings::import |
10 | 3 | 32µs | 2 | 20µs | # spent 17µs (13+3) within IO::Uncompress::Gunzip::BEGIN@10 which was called:
# once (13µs+3µs) by Compress::Zlib::BEGIN@14 at line 10 # spent 17µs making 1 call to IO::Uncompress::Gunzip::BEGIN@10
# spent 3µs making 1 call to bytes::import |
11 | |||||
12 | 3 | 183µs | 3 | 13.9ms | # spent 13.9ms (1.61+12.3) within IO::Uncompress::Gunzip::BEGIN@12 which was called:
# once (1.61ms+12.3ms) by Compress::Zlib::BEGIN@14 at line 12 # spent 13.9ms making 1 call to IO::Uncompress::Gunzip::BEGIN@12
# spent 28µs making 1 call to Exporter::import
# spent 16µs making 1 call to UNIVERSAL::VERSION |
13 | |||||
14 | 3 | 58µs | 3 | 119µs | # spent 68µs (16+52) within IO::Uncompress::Gunzip::BEGIN@14 which was called:
# once (16µs+52µs) by Compress::Zlib::BEGIN@14 at line 14 # spent 68µs making 1 call to IO::Uncompress::Gunzip::BEGIN@14
# spent 37µs making 1 call to Exporter::import
# spent 15µs making 1 call to UNIVERSAL::VERSION |
15 | 3 | 57µs | 3 | 342µs | # spent 178µs (15+163) within IO::Uncompress::Gunzip::BEGIN@15 which was called:
# once (15µs+163µs) by Compress::Zlib::BEGIN@14 at line 15 # spent 178µs making 1 call to IO::Uncompress::Gunzip::BEGIN@15
# spent 150µs making 1 call to Exporter::import
# spent 13µs making 1 call to UNIVERSAL::VERSION |
16 | 3 | 61µs | 3 | 749µs | # spent 384µs (19+365) within IO::Uncompress::Gunzip::BEGIN@16 which was called:
# once (19µs+365µs) by Compress::Zlib::BEGIN@14 at line 16 # spent 384µs making 1 call to IO::Uncompress::Gunzip::BEGIN@16
# spent 350µs making 1 call to Exporter::import
# spent 15µs making 1 call to UNIVERSAL::VERSION |
17 | 3 | 223µs | 2 | 44µs | # spent 30µs (15+15) within IO::Uncompress::Gunzip::BEGIN@17 which was called:
# once (15µs+15µs) by Compress::Zlib::BEGIN@14 at line 17 # spent 30µs making 1 call to IO::Uncompress::Gunzip::BEGIN@17
# spent 15µs making 1 call to UNIVERSAL::VERSION |
18 | |||||
19 | 1 | 700ns | require Exporter ; | ||
20 | |||||
21 | 1 | 1µs | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $GunzipError); | ||
22 | |||||
23 | 1 | 20µs | @ISA = qw( Exporter IO::Uncompress::RawInflate ); | ||
24 | 1 | 900ns | @EXPORT_OK = qw( $GunzipError gunzip ); | ||
25 | 1 | 1µs | %EXPORT_TAGS = %IO::Uncompress::RawInflate::DEFLATE_CONSTANTS ; | ||
26 | 1 | 2µs | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | ||
27 | 1 | 4µs | 1 | 26µs | Exporter::export_ok_tags('all'); # spent 26µs making 1 call to Exporter::export_ok_tags |
28 | |||||
29 | 1 | 700ns | $GunzipError = ''; | ||
30 | |||||
31 | 1 | 500ns | $VERSION = '2.020'; | ||
32 | |||||
33 | sub new | ||||
34 | { | ||||
35 | my $class = shift ; | ||||
36 | $GunzipError = ''; | ||||
37 | my $obj = createSelfTiedObject($class, \$GunzipError); | ||||
38 | |||||
39 | $obj->_create(undef, 0, @_); | ||||
40 | } | ||||
41 | |||||
42 | sub gunzip | ||||
43 | { | ||||
44 | my $obj = createSelfTiedObject(undef, \$GunzipError); | ||||
45 | return $obj->_inf(@_) ; | ||||
46 | } | ||||
47 | |||||
48 | sub getExtraParams | ||||
49 | { | ||||
50 | 3 | 1.20ms | 3 | 398µs | # spent 211µs (23+187) within IO::Uncompress::Gunzip::BEGIN@50 which was called:
# once (23µs+187µs) by Compress::Zlib::BEGIN@14 at line 50 # spent 211µs making 1 call to IO::Uncompress::Gunzip::BEGIN@50
# spent 169µs making 1 call to Exporter::import
# spent 18µs making 1 call to UNIVERSAL::VERSION |
51 | return ( 'ParseExtra' => [1, 1, Parse_boolean, 0] ) ; | ||||
52 | } | ||||
53 | |||||
54 | sub ckParams | ||||
55 | { | ||||
56 | my $self = shift ; | ||||
57 | my $got = shift ; | ||||
58 | |||||
59 | # gunzip always needs crc32 | ||||
60 | $got->value('CRC32' => 1); | ||||
61 | |||||
62 | return 1; | ||||
63 | } | ||||
64 | |||||
65 | sub ckMagic | ||||
66 | { | ||||
67 | my $self = shift; | ||||
68 | |||||
69 | my $magic ; | ||||
70 | $self->smartReadExact(\$magic, GZIP_ID_SIZE); | ||||
71 | |||||
72 | *$self->{HeaderPending} = $magic ; | ||||
73 | |||||
74 | return $self->HeaderError("Minimum header size is " . | ||||
75 | GZIP_MIN_HEADER_SIZE . " bytes") | ||||
76 | if length $magic != GZIP_ID_SIZE ; | ||||
77 | |||||
78 | return $self->HeaderError("Bad Magic") | ||||
79 | if ! isGzipMagic($magic) ; | ||||
80 | |||||
81 | *$self->{Type} = 'rfc1952'; | ||||
82 | |||||
83 | return $magic ; | ||||
84 | } | ||||
85 | |||||
86 | sub readHeader | ||||
87 | { | ||||
88 | my $self = shift; | ||||
89 | my $magic = shift; | ||||
90 | |||||
91 | return $self->_readGzipHeader($magic); | ||||
92 | } | ||||
93 | |||||
94 | sub chkTrailer | ||||
95 | { | ||||
96 | my $self = shift; | ||||
97 | my $trailer = shift; | ||||
98 | |||||
99 | # Check CRC & ISIZE | ||||
100 | my ($CRC32, $ISIZE) = unpack("V V", $trailer) ; | ||||
101 | *$self->{Info}{CRC32} = $CRC32; | ||||
102 | *$self->{Info}{ISIZE} = $ISIZE; | ||||
103 | |||||
104 | if (*$self->{Strict}) { | ||||
105 | return $self->TrailerError("CRC mismatch") | ||||
106 | if $CRC32 != *$self->{Uncomp}->crc32() ; | ||||
107 | |||||
108 | my $exp_isize = *$self->{UnCompSize}->get32bit(); | ||||
109 | return $self->TrailerError("ISIZE mismatch. Got $ISIZE" | ||||
110 | . ", expected $exp_isize") | ||||
111 | if $ISIZE != $exp_isize ; | ||||
112 | } | ||||
113 | |||||
114 | return STATUS_OK; | ||||
115 | } | ||||
116 | |||||
117 | sub isGzipMagic | ||||
118 | { | ||||
119 | my $buffer = shift ; | ||||
120 | return 0 if length $buffer < GZIP_ID_SIZE ; | ||||
121 | my ($id1, $id2) = unpack("C C", $buffer) ; | ||||
122 | return $id1 == GZIP_ID1 && $id2 == GZIP_ID2 ; | ||||
123 | } | ||||
124 | |||||
125 | sub _readFullGzipHeader($) | ||||
126 | { | ||||
127 | my ($self) = @_ ; | ||||
128 | my $magic = '' ; | ||||
129 | |||||
130 | $self->smartReadExact(\$magic, GZIP_ID_SIZE); | ||||
131 | |||||
132 | *$self->{HeaderPending} = $magic ; | ||||
133 | |||||
134 | return $self->HeaderError("Minimum header size is " . | ||||
135 | GZIP_MIN_HEADER_SIZE . " bytes") | ||||
136 | if length $magic != GZIP_ID_SIZE ; | ||||
137 | |||||
138 | |||||
139 | return $self->HeaderError("Bad Magic") | ||||
140 | if ! isGzipMagic($magic) ; | ||||
141 | |||||
142 | my $status = $self->_readGzipHeader($magic); | ||||
143 | delete *$self->{Transparent} if ! defined $status ; | ||||
144 | return $status ; | ||||
145 | } | ||||
146 | |||||
147 | sub _readGzipHeader($) | ||||
148 | { | ||||
149 | my ($self, $magic) = @_ ; | ||||
150 | my ($HeaderCRC) ; | ||||
151 | my ($buffer) = '' ; | ||||
152 | |||||
153 | $self->smartReadExact(\$buffer, GZIP_MIN_HEADER_SIZE - GZIP_ID_SIZE) | ||||
154 | or return $self->HeaderError("Minimum header size is " . | ||||
155 | GZIP_MIN_HEADER_SIZE . " bytes") ; | ||||
156 | |||||
157 | my $keep = $magic . $buffer ; | ||||
158 | *$self->{HeaderPending} = $keep ; | ||||
159 | |||||
160 | # now split out the various parts | ||||
161 | my ($cm, $flag, $mtime, $xfl, $os) = unpack("C C V C C", $buffer) ; | ||||
162 | |||||
163 | $cm == GZIP_CM_DEFLATED | ||||
164 | or return $self->HeaderError("Not Deflate (CM is $cm)") ; | ||||
165 | |||||
166 | # check for use of reserved bits | ||||
167 | return $self->HeaderError("Use of Reserved Bits in FLG field.") | ||||
168 | if $flag & GZIP_FLG_RESERVED ; | ||||
169 | |||||
170 | my $EXTRA ; | ||||
171 | my @EXTRA = () ; | ||||
172 | if ($flag & GZIP_FLG_FEXTRA) { | ||||
173 | $EXTRA = "" ; | ||||
174 | $self->smartReadExact(\$buffer, GZIP_FEXTRA_HEADER_SIZE) | ||||
175 | or return $self->TruncatedHeader("FEXTRA Length") ; | ||||
176 | |||||
177 | my ($XLEN) = unpack("v", $buffer) ; | ||||
178 | $self->smartReadExact(\$EXTRA, $XLEN) | ||||
179 | or return $self->TruncatedHeader("FEXTRA Body"); | ||||
180 | $keep .= $buffer . $EXTRA ; | ||||
181 | |||||
182 | if ($XLEN && *$self->{'ParseExtra'}) { | ||||
183 | my $bad = IO::Compress::Zlib::Extra::parseRawExtra($EXTRA, | ||||
184 | \@EXTRA, 1, 1); | ||||
185 | return $self->HeaderError($bad) | ||||
186 | if defined $bad; | ||||
187 | } | ||||
188 | } | ||||
189 | |||||
190 | my $origname ; | ||||
191 | if ($flag & GZIP_FLG_FNAME) { | ||||
192 | $origname = "" ; | ||||
193 | while (1) { | ||||
194 | $self->smartReadExact(\$buffer, 1) | ||||
195 | or return $self->TruncatedHeader("FNAME"); | ||||
196 | last if $buffer eq GZIP_NULL_BYTE ; | ||||
197 | $origname .= $buffer | ||||
198 | } | ||||
199 | $keep .= $origname . GZIP_NULL_BYTE ; | ||||
200 | |||||
201 | return $self->HeaderError("Non ISO 8859-1 Character found in Name") | ||||
202 | if *$self->{Strict} && $origname =~ /$GZIP_FNAME_INVALID_CHAR_RE/o ; | ||||
203 | } | ||||
204 | |||||
205 | my $comment ; | ||||
206 | if ($flag & GZIP_FLG_FCOMMENT) { | ||||
207 | $comment = ""; | ||||
208 | while (1) { | ||||
209 | $self->smartReadExact(\$buffer, 1) | ||||
210 | or return $self->TruncatedHeader("FCOMMENT"); | ||||
211 | last if $buffer eq GZIP_NULL_BYTE ; | ||||
212 | $comment .= $buffer | ||||
213 | } | ||||
214 | $keep .= $comment . GZIP_NULL_BYTE ; | ||||
215 | |||||
216 | return $self->HeaderError("Non ISO 8859-1 Character found in Comment") | ||||
217 | if *$self->{Strict} && $comment =~ /$GZIP_FCOMMENT_INVALID_CHAR_RE/o ; | ||||
218 | } | ||||
219 | |||||
220 | if ($flag & GZIP_FLG_FHCRC) { | ||||
221 | $self->smartReadExact(\$buffer, GZIP_FHCRC_SIZE) | ||||
222 | or return $self->TruncatedHeader("FHCRC"); | ||||
223 | |||||
224 | $HeaderCRC = unpack("v", $buffer) ; | ||||
225 | my $crc16 = crc32($keep) & 0xFF ; | ||||
226 | |||||
227 | return $self->HeaderError("CRC16 mismatch.") | ||||
228 | if *$self->{Strict} && $crc16 != $HeaderCRC; | ||||
229 | |||||
230 | $keep .= $buffer ; | ||||
231 | } | ||||
232 | |||||
233 | # Assume compression method is deflated for xfl tests | ||||
234 | #if ($xfl) { | ||||
235 | #} | ||||
236 | |||||
237 | *$self->{Type} = 'rfc1952'; | ||||
238 | |||||
239 | return { | ||||
240 | 'Type' => 'rfc1952', | ||||
241 | 'FingerprintLength' => 2, | ||||
242 | 'HeaderLength' => length $keep, | ||||
243 | 'TrailerLength' => GZIP_TRAILER_SIZE, | ||||
244 | 'Header' => $keep, | ||||
245 | 'isMinimalHeader' => $keep eq GZIP_MINIMUM_HEADER ? 1 : 0, | ||||
246 | |||||
247 | 'MethodID' => $cm, | ||||
248 | 'MethodName' => $cm == GZIP_CM_DEFLATED ? "Deflated" : "Unknown" , | ||||
249 | 'TextFlag' => $flag & GZIP_FLG_FTEXT ? 1 : 0, | ||||
250 | 'HeaderCRCFlag' => $flag & GZIP_FLG_FHCRC ? 1 : 0, | ||||
251 | 'NameFlag' => $flag & GZIP_FLG_FNAME ? 1 : 0, | ||||
252 | 'CommentFlag' => $flag & GZIP_FLG_FCOMMENT ? 1 : 0, | ||||
253 | 'ExtraFlag' => $flag & GZIP_FLG_FEXTRA ? 1 : 0, | ||||
254 | 'Name' => $origname, | ||||
255 | 'Comment' => $comment, | ||||
256 | 'Time' => $mtime, | ||||
257 | 'OsID' => $os, | ||||
258 | 'OsName' => defined $GZIP_OS_Names{$os} | ||||
259 | ? $GZIP_OS_Names{$os} : "Unknown", | ||||
260 | 'HeaderCRC' => $HeaderCRC, | ||||
261 | 'Flags' => $flag, | ||||
262 | 'ExtraFlags' => $xfl, | ||||
263 | 'ExtraFieldRaw' => $EXTRA, | ||||
264 | 'ExtraField' => [ @EXTRA ], | ||||
265 | |||||
266 | |||||
267 | #'CompSize'=> $compsize, | ||||
268 | #'CRC32'=> $CRC32, | ||||
269 | #'OrigSize'=> $ISIZE, | ||||
270 | } | ||||
271 | } | ||||
272 | |||||
273 | |||||
274 | 1 | 16µs | 1; | ||
275 | |||||
276 | __END__ |