| Filename | /Users/ether/perl5/perlbrew/perls/36.0/lib/5.36.0/IO/Compress/Gzip.pm |
| Statements | Executed 34 statements in 2.90ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1.55ms | 35.5ms | IO::Compress::Gzip::BEGIN@11 |
| 1 | 1 | 1 | 1.44ms | 3.11ms | IO::Compress::Gzip::BEGIN@15 |
| 1 | 1 | 1 | 1.37ms | 1.74ms | IO::Compress::Gzip::BEGIN@16 |
| 1 | 1 | 1 | 29µs | 33µs | IO::Compress::Gzip::BEGIN@5 |
| 1 | 1 | 1 | 13µs | 15µs | IO::Compress::Gzip::BEGIN@7 |
| 1 | 1 | 1 | 9µs | 92µs | IO::Compress::Gzip::BEGIN@12 |
| 1 | 1 | 1 | 9µs | 44µs | IO::Compress::Gzip::BEGIN@6 |
| 1 | 1 | 1 | 8µs | 29µs | IO::Compress::Gzip::BEGIN@170 |
| 1 | 1 | 1 | 7µs | 72µs | IO::Compress::Gzip::BEGIN@14 |
| 1 | 1 | 1 | 3µs | 3µs | IO::Compress::Gzip::BEGIN@19 |
| 1 | 1 | 1 | 1µs | 1µs | IO::Compress::Gzip::__ANON__ (xsub) |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::__ANON__[:23] |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::ckParams |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::getExtraParams |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::getFileInfo |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::getInverseClass |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::gzip |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::mkFinalTrailer |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::mkHeader |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::mkTrailer |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::new |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package IO::Compress::Gzip ; | ||||
| 2 | |||||
| 3 | 1 | 7µs | require 5.006 ; | ||
| 4 | |||||
| 5 | 2 | 38µs | 2 | 37µs | # spent 33µs (29+4) within IO::Compress::Gzip::BEGIN@5 which was called:
# once (29µs+4µs) by Mojo::Util::BEGIN@12 at line 5 # spent 33µs making 1 call to IO::Compress::Gzip::BEGIN@5
# spent 4µs making 1 call to strict::import |
| 6 | 2 | 25µs | 2 | 79µs | # spent 44µs (9+35) within IO::Compress::Gzip::BEGIN@6 which was called:
# once (9µs+35µs) by Mojo::Util::BEGIN@12 at line 6 # spent 44µs making 1 call to IO::Compress::Gzip::BEGIN@6
# spent 35µs making 1 call to warnings::import |
| 7 | 2 | 32µs | 2 | 17µs | # spent 15µs (13+2) within IO::Compress::Gzip::BEGIN@7 which was called:
# once (13µs+2µs) by Mojo::Util::BEGIN@12 at line 7 # spent 15µs making 1 call to IO::Compress::Gzip::BEGIN@7
# spent 2µs making 1 call to bytes::import |
| 8 | |||||
| 9 | 1 | 0s | require Exporter ; | ||
| 10 | |||||
| 11 | 3 | 620µs | 2 | 35.5ms | # spent 35.5ms (1.55+33.9) within IO::Compress::Gzip::BEGIN@11 which was called:
# once (1.55ms+33.9ms) by Mojo::Util::BEGIN@12 at line 11 # spent 35.5ms making 1 call to IO::Compress::Gzip::BEGIN@11
# spent 5µs making 1 call to UNIVERSAL::VERSION |
| 12 | 3 | 26µs | 3 | 175µs | # spent 92µs (9+83) within IO::Compress::Gzip::BEGIN@12 which was called:
# once (9µs+83µs) by Mojo::Util::BEGIN@12 at line 12 # spent 92µs making 1 call to IO::Compress::Gzip::BEGIN@12
# spent 80µs making 1 call to Exporter::import
# spent 3µs making 1 call to UNIVERSAL::VERSION |
| 13 | |||||
| 14 | 3 | 22µs | 3 | 137µs | # spent 72µs (7+65) within IO::Compress::Gzip::BEGIN@14 which was called:
# once (7µs+65µs) by Mojo::Util::BEGIN@12 at line 14 # spent 72µs making 1 call to IO::Compress::Gzip::BEGIN@14
# spent 62µs making 1 call to Exporter::import
# spent 3µs making 1 call to UNIVERSAL::VERSION |
| 15 | 3 | 476µs | 3 | 3.36ms | # spent 3.11ms (1.44+1.66) within IO::Compress::Gzip::BEGIN@15 which was called:
# once (1.44ms+1.66ms) by Mojo::Util::BEGIN@12 at line 15 # spent 3.11ms making 1 call to IO::Compress::Gzip::BEGIN@15
# spent 241µs making 1 call to Exporter::import
# spent 13µs making 1 call to UNIVERSAL::VERSION |
| 16 | 3 | 625µs | 3 | 1.75ms | # spent 1.74ms (1.37+371µs) within IO::Compress::Gzip::BEGIN@16 which was called:
# once (1.37ms+371µs) by Mojo::Util::BEGIN@12 at line 16 # spent 1.74ms making 1 call to IO::Compress::Gzip::BEGIN@16
# spent 5µs making 1 call to UNIVERSAL::VERSION
# spent 1µs making 1 call to IO::Compress::Gzip::__ANON__ |
| 17 | |||||
| 18 | BEGIN | ||||
| 19 | # spent 3µs within IO::Compress::Gzip::BEGIN@19 which was called:
# once (3µs+0s) by Mojo::Util::BEGIN@12 at line 24 | ||||
| 20 | 1 | 4µs | if (defined &utf8::downgrade ) | ||
| 21 | { *noUTF8 = \&utf8::downgrade } | ||||
| 22 | else | ||||
| 23 | { *noUTF8 = sub {} } | ||||
| 24 | 1 | 550µs | 1 | 3µs | } # spent 3µs making 1 call to IO::Compress::Gzip::BEGIN@19 |
| 25 | |||||
| 26 | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $GzipError); | ||||
| 27 | |||||
| 28 | 1 | 0s | $VERSION = '2.106'; | ||
| 29 | 1 | 1µs | $GzipError = '' ; | ||
| 30 | |||||
| 31 | 1 | 12µs | @ISA = qw(IO::Compress::RawDeflate Exporter); | ||
| 32 | 1 | 0s | @EXPORT_OK = qw( $GzipError gzip ) ; | ||
| 33 | 1 | 5µs | %EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ; | ||
| 34 | |||||
| 35 | 1 | 2µs | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | ||
| 36 | 1 | 2µs | 1 | 17µs | Exporter::export_ok_tags('all'); # spent 17µs making 1 call to Exporter::export_ok_tags |
| 37 | |||||
| 38 | sub new | ||||
| 39 | { | ||||
| 40 | my $class = shift ; | ||||
| 41 | |||||
| 42 | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$GzipError); | ||||
| 43 | |||||
| 44 | $obj->_create(undef, @_); | ||||
| 45 | } | ||||
| 46 | |||||
| 47 | |||||
| 48 | sub gzip | ||||
| 49 | { | ||||
| 50 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$GzipError); | ||||
| 51 | return $obj->_def(@_); | ||||
| 52 | } | ||||
| 53 | |||||
| 54 | #sub newHeader | ||||
| 55 | #{ | ||||
| 56 | # my $self = shift ; | ||||
| 57 | # #return GZIP_MINIMUM_HEADER ; | ||||
| 58 | # return $self->mkHeader(*$self->{Got}); | ||||
| 59 | #} | ||||
| 60 | |||||
| 61 | sub getExtraParams | ||||
| 62 | { | ||||
| 63 | my $self = shift ; | ||||
| 64 | |||||
| 65 | return ( | ||||
| 66 | # zlib behaviour | ||||
| 67 | $self->getZlibParams(), | ||||
| 68 | |||||
| 69 | # Gzip header fields | ||||
| 70 | 'minimal' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
| 71 | 'comment' => [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 72 | 'name' => [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 73 | 'time' => [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 74 | 'textflag' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
| 75 | 'headercrc' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
| 76 | 'os_code' => [IO::Compress::Base::Common::Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code], | ||||
| 77 | 'extrafield'=> [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 78 | 'extraflags'=> [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 79 | |||||
| 80 | ); | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | |||||
| 84 | sub ckParams | ||||
| 85 | { | ||||
| 86 | my $self = shift ; | ||||
| 87 | my $got = shift ; | ||||
| 88 | |||||
| 89 | # gzip always needs crc32 | ||||
| 90 | $got->setValue('crc32' => 1); | ||||
| 91 | |||||
| 92 | return 1 | ||||
| 93 | if $got->getValue('merge') ; | ||||
| 94 | |||||
| 95 | my $strict = $got->getValue('strict') ; | ||||
| 96 | |||||
| 97 | |||||
| 98 | { | ||||
| 99 | if (! $got->parsed('time') ) { | ||||
| 100 | # Modification time defaults to now. | ||||
| 101 | $got->setValue(time => time) ; | ||||
| 102 | } | ||||
| 103 | |||||
| 104 | # Check that the Name & Comment don't have embedded NULLs | ||||
| 105 | # Also check that they only contain ISO 8859-1 chars. | ||||
| 106 | if ($got->parsed('name') && defined $got->getValue('name')) { | ||||
| 107 | my $name = $got->getValue('name'); | ||||
| 108 | |||||
| 109 | return $self->saveErrorString(undef, "Null Character found in Name", | ||||
| 110 | Z_DATA_ERROR) | ||||
| 111 | if $strict && $name =~ /\x00/ ; | ||||
| 112 | |||||
| 113 | return $self->saveErrorString(undef, "Non ISO 8859-1 Character found in Name", | ||||
| 114 | Z_DATA_ERROR) | ||||
| 115 | if $strict && $name =~ /$GZIP_FNAME_INVALID_CHAR_RE/o ; | ||||
| 116 | } | ||||
| 117 | |||||
| 118 | if ($got->parsed('comment') && defined $got->getValue('comment')) { | ||||
| 119 | my $comment = $got->getValue('comment'); | ||||
| 120 | |||||
| 121 | return $self->saveErrorString(undef, "Null Character found in Comment", | ||||
| 122 | Z_DATA_ERROR) | ||||
| 123 | if $strict && $comment =~ /\x00/ ; | ||||
| 124 | |||||
| 125 | return $self->saveErrorString(undef, "Non ISO 8859-1 Character found in Comment", | ||||
| 126 | Z_DATA_ERROR) | ||||
| 127 | if $strict && $comment =~ /$GZIP_FCOMMENT_INVALID_CHAR_RE/o; | ||||
| 128 | } | ||||
| 129 | |||||
| 130 | if ($got->parsed('os_code') ) { | ||||
| 131 | my $value = $got->getValue('os_code'); | ||||
| 132 | |||||
| 133 | return $self->saveErrorString(undef, "OS_Code must be between 0 and 255, got '$value'") | ||||
| 134 | if $value < 0 || $value > 255 ; | ||||
| 135 | |||||
| 136 | } | ||||
| 137 | |||||
| 138 | # gzip only supports Deflate at present | ||||
| 139 | $got->setValue('method' => Z_DEFLATED) ; | ||||
| 140 | |||||
| 141 | if ( ! $got->parsed('extraflags')) { | ||||
| 142 | $got->setValue('extraflags' => 2) | ||||
| 143 | if $got->getValue('level') == Z_BEST_COMPRESSION ; | ||||
| 144 | $got->setValue('extraflags' => 4) | ||||
| 145 | if $got->getValue('level') == Z_BEST_SPEED ; | ||||
| 146 | } | ||||
| 147 | |||||
| 148 | my $data = $got->getValue('extrafield') ; | ||||
| 149 | if (defined $data) { | ||||
| 150 | my $bad = IO::Compress::Zlib::Extra::parseExtraField($data, $strict, 1) ; | ||||
| 151 | return $self->saveErrorString(undef, "Error with ExtraField Parameter: $bad", Z_DATA_ERROR) | ||||
| 152 | if $bad ; | ||||
| 153 | |||||
| 154 | $got->setValue('extrafield' => $data) ; | ||||
| 155 | } | ||||
| 156 | } | ||||
| 157 | |||||
| 158 | return 1; | ||||
| 159 | } | ||||
| 160 | |||||
| 161 | sub mkTrailer | ||||
| 162 | { | ||||
| 163 | my $self = shift ; | ||||
| 164 | return pack("V V", *$self->{Compress}->crc32(), | ||||
| 165 | *$self->{UnCompSize}->get32bit()); | ||||
| 166 | } | ||||
| 167 | |||||
| 168 | sub getInverseClass | ||||
| 169 | { | ||||
| 170 | 2 | 448µs | 2 | 50µs | # spent 29µs (8+21) within IO::Compress::Gzip::BEGIN@170 which was called:
# once (8µs+21µs) by Mojo::Util::BEGIN@12 at line 170 # spent 29µs making 1 call to IO::Compress::Gzip::BEGIN@170
# spent 21µs making 1 call to warnings::unimport |
| 171 | return ('IO::Uncompress::Gunzip', | ||||
| 172 | \$IO::Uncompress::Gunzip::GunzipError); | ||||
| 173 | } | ||||
| 174 | |||||
| 175 | sub getFileInfo | ||||
| 176 | { | ||||
| 177 | my $self = shift ; | ||||
| 178 | my $params = shift; | ||||
| 179 | my $filename = shift ; | ||||
| 180 | |||||
| 181 | return if IO::Compress::Base::Common::isaScalar($filename); | ||||
| 182 | |||||
| 183 | my $defaultTime = (stat($filename))[9] ; | ||||
| 184 | |||||
| 185 | $params->setValue('name' => $filename) | ||||
| 186 | if ! $params->parsed('name') ; | ||||
| 187 | |||||
| 188 | $params->setValue('time' => $defaultTime) | ||||
| 189 | if ! $params->parsed('time') ; | ||||
| 190 | } | ||||
| 191 | |||||
| 192 | |||||
| 193 | sub mkHeader | ||||
| 194 | { | ||||
| 195 | my $self = shift ; | ||||
| 196 | my $param = shift ; | ||||
| 197 | |||||
| 198 | # short-circuit if a minimal header is requested. | ||||
| 199 | return GZIP_MINIMUM_HEADER if $param->getValue('minimal') ; | ||||
| 200 | |||||
| 201 | # METHOD | ||||
| 202 | my $method = $param->valueOrDefault('method', GZIP_CM_DEFLATED) ; | ||||
| 203 | |||||
| 204 | # FLAGS | ||||
| 205 | my $flags = GZIP_FLG_DEFAULT ; | ||||
| 206 | $flags |= GZIP_FLG_FTEXT if $param->getValue('textflag') ; | ||||
| 207 | $flags |= GZIP_FLG_FHCRC if $param->getValue('headercrc') ; | ||||
| 208 | $flags |= GZIP_FLG_FEXTRA if $param->wantValue('extrafield') ; | ||||
| 209 | $flags |= GZIP_FLG_FNAME if $param->wantValue('name') ; | ||||
| 210 | $flags |= GZIP_FLG_FCOMMENT if $param->wantValue('comment') ; | ||||
| 211 | |||||
| 212 | # MTIME | ||||
| 213 | my $time = $param->valueOrDefault('time', GZIP_MTIME_DEFAULT) ; | ||||
| 214 | |||||
| 215 | # EXTRA FLAGS | ||||
| 216 | my $extra_flags = $param->valueOrDefault('extraflags', GZIP_XFL_DEFAULT); | ||||
| 217 | |||||
| 218 | # OS CODE | ||||
| 219 | my $os_code = $param->valueOrDefault('os_code', GZIP_OS_DEFAULT) ; | ||||
| 220 | |||||
| 221 | |||||
| 222 | my $out = pack("C4 V C C", | ||||
| 223 | GZIP_ID1, # ID1 | ||||
| 224 | GZIP_ID2, # ID2 | ||||
| 225 | $method, # Compression Method | ||||
| 226 | $flags, # Flags | ||||
| 227 | $time, # Modification Time | ||||
| 228 | $extra_flags, # Extra Flags | ||||
| 229 | $os_code, # Operating System Code | ||||
| 230 | ) ; | ||||
| 231 | |||||
| 232 | # EXTRA | ||||
| 233 | if ($flags & GZIP_FLG_FEXTRA) { | ||||
| 234 | my $extra = $param->getValue('extrafield') ; | ||||
| 235 | $out .= pack("v", length $extra) . $extra ; | ||||
| 236 | } | ||||
| 237 | |||||
| 238 | # NAME | ||||
| 239 | if ($flags & GZIP_FLG_FNAME) { | ||||
| 240 | my $name .= $param->getValue('name') ; | ||||
| 241 | $name =~ s/\x00.*$//; | ||||
| 242 | $out .= $name ; | ||||
| 243 | # Terminate the filename with NULL unless it already is | ||||
| 244 | $out .= GZIP_NULL_BYTE | ||||
| 245 | if !length $name or | ||||
| 246 | substr($name, 1, -1) ne GZIP_NULL_BYTE ; | ||||
| 247 | } | ||||
| 248 | |||||
| 249 | # COMMENT | ||||
| 250 | if ($flags & GZIP_FLG_FCOMMENT) { | ||||
| 251 | my $comment .= $param->getValue('comment') ; | ||||
| 252 | $comment =~ s/\x00.*$//; | ||||
| 253 | $out .= $comment ; | ||||
| 254 | # Terminate the comment with NULL unless it already is | ||||
| 255 | $out .= GZIP_NULL_BYTE | ||||
| 256 | if ! length $comment or | ||||
| 257 | substr($comment, 1, -1) ne GZIP_NULL_BYTE; | ||||
| 258 | } | ||||
| 259 | |||||
| 260 | # HEADER CRC | ||||
| 261 | $out .= pack("v", Compress::Raw::Zlib::crc32($out) & 0x00FF ) | ||||
| 262 | if $param->getValue('headercrc') ; | ||||
| 263 | |||||
| 264 | noUTF8($out); | ||||
| 265 | |||||
| 266 | return $out ; | ||||
| 267 | } | ||||
| 268 | |||||
| 269 | sub mkFinalTrailer | ||||
| 270 | { | ||||
| 271 | return ''; | ||||
| 272 | } | ||||
| 273 | |||||
| 274 | 1 | 8µs | 1; | ||
| 275 | |||||
| 276 | __END__ | ||||
# spent 1µs within IO::Compress::Gzip::__ANON__ which was called:
# once (1µs+0s) by IO::Compress::Gzip::BEGIN@16 at line 16 |