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