Skip to content

Commit

Permalink
add some _trace just for good measure
Browse files Browse the repository at this point in the history
  • Loading branch information
grawity committed Jul 15, 2019
1 parent 948ed96 commit fe3f8e3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion getpaste
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ my $opt_batch = 0;

BEGIN {
if (eval {require Nullroute::Lib}) {
Nullroute::Lib->import(qw(_debug _warn _err _die));
Nullroute::Lib->import(qw(_trace _debug _warn _err _die));
} else {
$::arg0 = (split m!/!, $0)[-1];
$::debug = !!$ENV{DEBUG};
$::warnings = 0;
$::errors = 0;
sub _trace { warn "trace: @_\n" if $::debug; }
sub _debug { warn "debug: @_\n" if $::debug; }
sub _warn { warn "warning: @_\n"; ++$::warnings; }
sub _err { warn "error: @_\n"; ! ++$::errors; }
Expand Down Expand Up @@ -360,22 +361,27 @@ sub decompress_zlib {
if ($opt{is_gzip_or_zlib}) {
# autodetect RFC 1950 (zlib) or 1952 (gzip)
$wbits = Compress::Raw::Zlib->WANT_GZIP_OR_ZLIB;
_trace("using WindowBits = $wbits (WANT_GZIP_OR_ZLIB, detect 1950/1952)");
}
elsif ($opt{is_gzip}) {
# expect RFC 1952 (gzip)
$wbits = Compress::Raw::Zlib->WANT_GZIP;
_trace("using WindowBits = $wbits (WANT_GZIP, expect 1952)");
}
elsif ($opt{is_deflate}) {
# expect RFC 1951 (deflate)
$wbits = -Compress::Raw::Zlib->MAX_WBITS;
_trace("using WindowBits = $wbits (-MAX_WBITS, expect 1951 deflate)");
}
elsif ($opt{is_zlib}) {
# expect RFC 1950 (zlib)
$wbits = 15;
_trace("using WindowBits = $wbits (expect 1950 zlib)");
}
else {
# mirror the zlib default
$wbits = Compress::Raw::Zlib->MAX_WBITS;
_trace("using WindowBits = $wbits (MAX_WBITS, default)");
}

($stream, $status) = Compress::Raw::Zlib::Inflate->new(-WindowBits => $wbits);
Expand Down

0 comments on commit fe3f8e3

Please sign in to comment.