In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/70a3f1a0a56a8c0efab1e550af3003124605d322?hp=e9f2c446ed77eec13aad13748ac1b503b0cc3304>
- Log ----------------------------------------------------------------- commit 70a3f1a0a56a8c0efab1e550af3003124605d322 Author: James E Keenan <[email protected]> Date: Wed Mar 8 21:40:27 2017 -0500 Sync Compress-Raw-Zlib with CPAN version 2.074. M Porting/Maintainers.pl M cpan/Compress-Raw-Zlib/Makefile.PL M cpan/Compress-Raw-Zlib/Zlib.xs M cpan/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm M cpan/Compress-Raw-Zlib/t/02zlib.t M cpan/Compress-Raw-Zlib/t/compress/CompTestUtils.pm M cpan/Compress-Raw-Zlib/zlib-src/inflate.c commit 328668c77c7ebd8017f207e294a4b50b629d4acf Author: James E Keenan <[email protected]> Date: Wed Mar 8 21:28:01 2017 -0500 Sync Compress-Raw-Bzip2 with CPAN version 2.074. M Porting/Maintainers.pl M cpan/Compress-Raw-Bzip2/Makefile.PL M cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm M cpan/Compress-Raw-Bzip2/t/000prereq.t M cpan/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm ----------------------------------------------------------------------- Summary of changes: Porting/Maintainers.pl | 4 +- cpan/Compress-Raw-Bzip2/Makefile.PL | 1 + cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm | 4 +- cpan/Compress-Raw-Bzip2/t/000prereq.t | 2 +- .../Compress-Raw-Bzip2/t/compress/CompTestUtils.pm | 17 +- cpan/Compress-Raw-Zlib/Makefile.PL | 1 + cpan/Compress-Raw-Zlib/Zlib.xs | 224 ++++++++++++++++----- cpan/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm | 4 +- cpan/Compress-Raw-Zlib/t/02zlib.t | 11 +- cpan/Compress-Raw-Zlib/t/compress/CompTestUtils.pm | 17 +- cpan/Compress-Raw-Zlib/zlib-src/inflate.c | 9 +- 11 files changed, 224 insertions(+), 70 deletions(-) diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index ca66df6d06..96ea67bc60 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -206,7 +206,7 @@ use File::Glob qw(:case); }, 'Compress::Raw::Bzip2' => { - 'DISTRIBUTION' => 'PMQS/Compress-Raw-Bzip2-2.070.tar.gz', + 'DISTRIBUTION' => 'PMQS/Compress-Raw-Bzip2-2.074.tar.gz', 'FILES' => q[cpan/Compress-Raw-Bzip2], 'EXCLUDED' => [ qr{^t/Test/}, @@ -217,7 +217,7 @@ use File::Glob qw(:case); }, 'Compress::Raw::Zlib' => { - 'DISTRIBUTION' => 'PMQS/Compress-Raw-Zlib-2.070.tar.gz', + 'DISTRIBUTION' => 'PMQS/Compress-Raw-Zlib-2.074.tar.gz', 'FILES' => q[cpan/Compress-Raw-Zlib], 'EXCLUDED' => [ diff --git a/cpan/Compress-Raw-Bzip2/Makefile.PL b/cpan/Compress-Raw-Bzip2/Makefile.PL index efcdf3f613..246259d335 100644 --- a/cpan/Compress-Raw-Bzip2/Makefile.PL +++ b/cpan/Compress-Raw-Bzip2/Makefile.PL @@ -3,6 +3,7 @@ use strict ; require 5.006 ; +use lib '.'; use private::MakeUtil; use ExtUtils::MakeMaker 5.16 ; diff --git a/cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm b/cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm index 0d806b969b..ce5245fe4b 100644 --- a/cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm +++ b/cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm @@ -11,7 +11,7 @@ use Carp ; use bytes ; our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD); -$VERSION = '2.070'; +$VERSION = '2.074'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -378,7 +378,7 @@ See the Changes file. =head1 COPYRIGHT AND LICENSE -Copyright (c) 2005-2016 Paul Marquess. All rights reserved. +Copyright (c) 2005-2017 Paul Marquess. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/cpan/Compress-Raw-Bzip2/t/000prereq.t b/cpan/Compress-Raw-Bzip2/t/000prereq.t index 63945c3038..3220a7fc14 100644 --- a/cpan/Compress-Raw-Bzip2/t/000prereq.t +++ b/cpan/Compress-Raw-Bzip2/t/000prereq.t @@ -19,7 +19,7 @@ BEGIN if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - my $VERSION = '2.070'; + my $VERSION = '2.074'; my @NAMES = qw( ); diff --git a/cpan/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm b/cpan/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm index 9815eb2caa..da238e15d2 100644 --- a/cpan/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm +++ b/cpan/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm @@ -70,8 +70,8 @@ BEGIN { our ($index); $index = '00000'; - our ($useTempFile) = defined &File::Temp::tempdir; - our ($useTempDir) = defined &File::Temp::newdir; + our ($useTempFile); + our ($useTempDir); sub new { @@ -115,7 +115,12 @@ BEGIN { # autogenerate the name if none supplied $_ = "tmpdir" . $$ . "X" . $index ++ . ".tmp" ; } - foreach (@_) { rmtree $_; mkdir $_, 0777 } + foreach (@_) + { + rmtree $_, {verbose => 0, safe => 1} + if -d $_; + mkdir $_, 0777 + } bless [ @_ ], $self ; } @@ -126,7 +131,11 @@ BEGIN { if (! $useTempFile) { my $self = shift ; - foreach (@$self) { rmtree $_ } + foreach (@$self) + { + rmtree $_, {verbose => 0, safe => 1} + if -d $_ ; + } } } } diff --git a/cpan/Compress-Raw-Zlib/Makefile.PL b/cpan/Compress-Raw-Zlib/Makefile.PL index 015c1d9a13..028f550c24 100644 --- a/cpan/Compress-Raw-Zlib/Makefile.PL +++ b/cpan/Compress-Raw-Zlib/Makefile.PL @@ -3,6 +3,7 @@ use strict ; require 5.006 ; +use lib '.'; use private::MakeUtil; use ExtUtils::MakeMaker 5.16 ; use ExtUtils::Install (); # only needed to check for version diff --git a/cpan/Compress-Raw-Zlib/Zlib.xs b/cpan/Compress-Raw-Zlib/Zlib.xs index d379f7872d..3ac936c040 100644 --- a/cpan/Compress-Raw-Zlib/Zlib.xs +++ b/cpan/Compress-Raw-Zlib/Zlib.xs @@ -74,6 +74,10 @@ # define AT_LEAST_ZLIB_1_2_8 #endif +#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1290 +# define AT_LEAST_ZLIB_1_2_9 +#endif + #ifdef USE_PPPORT_H # define NEED_sv_2pvbyte # define NEED_sv_2pv_nolen @@ -134,12 +138,13 @@ typedef struct di_stream { uLong dict_adler ; int last_error ; bool zip_mode ; -#define SETP_BYTE +/* #define SETP_BYTE */ #ifdef SETP_BYTE + /* SETP_BYTE only works with zlib up to 1.2.8 */ bool deflateParams_out_valid ; Bytef deflateParams_out_byte; #else -#define deflateParams_BUFFER_SIZE 0x4000 +#define deflateParams_BUFFER_SIZE 0x40000 uLong deflateParams_out_length; Bytef* deflateParams_out_buffer; #endif @@ -636,6 +641,103 @@ char * string ; return sv ; } +#if 0 +int +flushToBuffer(di_stream* s, int flush) +{ + dTHX; + int ret ; + z_stream * strm = &s->stream; + + Bytef* output = s->deflateParams_out_buffer ; + + strm->next_in = NULL; + strm->avail_in = 0; + + uLong total_output = 0; + uLong have = 0; + + do + { + if (output) + output = (unsigned char *)saferealloc(output, total_output + s->bufsize); + else + output = (unsigned char *)safemalloc(s->bufsize); + + strm->next_out = output + total_output; + strm->avail_out = s->bufsize; + + ret = deflate(strm, flush); /* no bad return value */ + //assert(ret != Z_STREAM_ERROR); /* state not clobbered */ + if(ret == Z_STREAM_ERROR) + { + safefree(output); + return ret; + } + have = s->bufsize - strm->avail_out; + total_output += have; + + //fprintf(stderr, "FLUSH %s %d, return %d\n", flush_flags[flush], have, ret); + + } while (strm->avail_out == 0); + + s->deflateParams_out_buffer = output; + s->deflateParams_out_length = total_output; + + return Z_OK; +} +#endif + +#ifndef SETP_BYTE +int +flushParams(di_stream* s) +{ + dTHX; + int ret ; + z_stream * strm = &s->stream; + + Bytef* output = s->deflateParams_out_buffer ; + uLong total_output = s->deflateParams_out_length; + uLong have = 0; + + strm->next_in = NULL; + strm->avail_in = 0; + + + do + { + if (output) + output = (unsigned char *)saferealloc(output, total_output + s->bufsize); + else + output = (unsigned char *)safemalloc(s->bufsize); + + strm->next_out = output + total_output; + strm->avail_out = s->bufsize; + + ret = deflateParams(&(s->stream), s->Level, s->Strategy); + /* fprintf(stderr, "deflateParams %d %s %lu\n", ret, + GetErrorString(ret), s->bufsize - strm->avail_out); */ + + if (ret == Z_STREAM_ERROR) + break; + + have = s->bufsize - strm->avail_out; + total_output += have; + + + } while (ret == Z_BUF_ERROR) ; + + if(ret == Z_STREAM_ERROR) + safefree(output); + else + { + s->deflateParams_out_buffer = output; + s->deflateParams_out_length = total_output; + } + + return ret; +} +#endif /* ! SETP_BYTE */ #include "constants.h" @@ -991,20 +1093,24 @@ deflate (s, buf, output) /* Check for saved output from deflateParams */ if (s->deflateParams_out_length) { uLong plen = s->deflateParams_out_length ; - /* printf("Copy %d bytes saved data\n", plen);*/ + /* printf("Copy %lu bytes saved data\n", plen); */ if (s->stream.avail_out < plen) { - /*printf("GROW from %d to %d\n", s->stream.avail_out, - SvLEN(output) + plen - s->stream.avail_out); */ - Sv_Grow(output, SvLEN(output) + plen - s->stream.avail_out) ; + /* printf("GROW from %d to %lu\n", s->stream.avail_out, + SvLEN(output) + plen - s->stream.avail_out); */ + s->stream.next_out = (Bytef*) Sv_Grow(output, SvLEN(output) + plen - s->stream.avail_out) ; + s->stream.next_out += cur_length; } - Copy(s->stream.next_out, s->deflateParams_out_buffer, plen, Bytef) ; - cur_length = cur_length + plen; + Copy(s->deflateParams_out_buffer, s->stream.next_out, plen, Bytef) ; + cur_length += plen; SvCUR_set(output, cur_length); - s->stream.next_out += plen ; - s->stream.avail_out = SvLEN(output) - cur_length ; - increment = s->stream.avail_out; - s->deflateParams_out_length = 0; + s->stream.next_out += plen ; + s->stream.avail_out = SvLEN(output) - cur_length ; + increment = s->stream.avail_out; + + s->deflateParams_out_length = 0; + Safefree(s->deflateParams_out_buffer); + s->deflateParams_out_buffer = NULL; } #endif RETVAL = Z_OK ; @@ -1027,6 +1133,14 @@ deflate (s, buf, output) } RETVAL = deflate(&(s->stream), Z_NO_FLUSH); + /* + if (RETVAL != Z_STREAM_ERROR) { + int done = increment - s->stream.avail_out ; + printf("std DEFLATEr returned %d '%s' avail in %d, out %d wrote %d\n", RETVAL, + GetErrorString(RETVAL), s->stream.avail_in, +s->stream.avail_out, done); + } + */ if (trace) { printf("DEFLATE returned %d %s, avail in %d, out %d\n", RETVAL, @@ -1080,7 +1194,6 @@ flush(s, output, f=Z_FINISH) CODE: bufinc = s->bufsize; - s->stream.avail_in = 0; /* should be zero already anyway */ /* retrieve the output buffer */ output = deRef_l(output, "flush") ; @@ -1108,20 +1221,24 @@ flush(s, output, f=Z_FINISH) /* Check for saved output from deflateParams */ if (s->deflateParams_out_length) { uLong plen = s->deflateParams_out_length ; - /* printf("Copy %d bytes saved data\n", plen); */ + /* printf("Copy %lu bytes saved data\n", plen); */ if (s->stream.avail_out < plen) { - /* printf("GROW from %d to %d\n", s->stream.avail_out, + /* printf("GROW from %d to %lu\n", s->stream.avail_out, SvLEN(output) + plen - s->stream.avail_out); */ - Sv_Grow(output, SvLEN(output) + plen - s->stream.avail_out) ; + s->stream.next_out = (Bytef*) Sv_Grow(output, SvLEN(output) + plen - s->stream.avail_out) ; + s->stream.next_out += cur_length; } - Copy(s->stream.next_out, s->deflateParams_out_buffer, plen, Bytef) ; - cur_length = cur_length + plen; + Copy(s->deflateParams_out_buffer, s->stream.next_out, plen, Bytef) ; + cur_length += plen; SvCUR_set(output, cur_length); - s->stream.next_out += plen ; - s->stream.avail_out = SvLEN(output) - cur_length ; - increment = s->stream.avail_out; - s->deflateParams_out_length = 0; + s->stream.next_out += plen ; + s->stream.avail_out = SvLEN(output) - cur_length ; + increment = s->stream.avail_out; + + s->deflateParams_out_length = 0; + Safefree(s->deflateParams_out_buffer); + s->deflateParams_out_buffer = NULL; } #endif @@ -1145,9 +1262,17 @@ flush(s, output, f=Z_FINISH) } RETVAL = deflate(&(s->stream), f); + /* + if (RETVAL != Z_STREAM_ERROR) { + int done = availableout - s->stream.avail_out ; + printf("flush DEFLATEr returned %d '%s' avail in %d, out %d wrote %d\n", RETVAL, + GetErrorString(RETVAL), s->stream.avail_in, +s->stream.avail_out, done); + } + */ if (trace) { - printf("flush DEFLATE returned %d %s, avail in %d, out %d\n", RETVAL, + printf("flush DEFLATE returned %d '%s', avail in %d, out %d\n", RETVAL, GetErrorString(RETVAL), s->stream.avail_in, s->stream.avail_out); DispStream(s, "AFTER"); } @@ -1184,41 +1309,38 @@ _deflateParams(s, flags, level, strategy, bufsize) int level int strategy uLong bufsize + bool changed = FALSE; CODE: - /* printf("_deflateParams(Flags %d Level %d Strategy %d Bufsize %d)\n", flags, level, strategy, bufsize); - printf("Before -- Level %d, Strategy %d, Bufsize %d\n", s->Level, s->Strategy, s->bufsize); */ - if (flags & 1) - s->Level = level ; - if (flags & 2) - s->Strategy = strategy ; - if (flags & 4) { + /* printf("_deflateParams(Flags %d Level %d Strategy %d Bufsize %d)\n", flags, level, strategy, bufsize); + printf("Before -- Level %d, Strategy %d, Bufsize %d\n", s->Level, s->Strategy, s->bufsize); */ + if (flags & 1 && level != s->Level) { + s->Level = level ; + changed = TRUE; + } + if (flags & 2 && strategy != s->Strategy) { + s->Strategy = strategy ; + changed = TRUE; + } + if (flags & 4) s->bufsize = bufsize; - } - /* printf("After -- Level %d, Strategy %d, Bufsize %d\n", s->Level, s->Strategy, s->bufsize);*/ + if (changed) { #ifdef SETP_BYTE - s->stream.avail_in = 0; - s->stream.next_out = &(s->deflateParams_out_byte) ; - s->stream.avail_out = 1; - RETVAL = deflateParams(&(s->stream), s->Level, s->Strategy); - s->deflateParams_out_valid = - (RETVAL == Z_OK && s->stream.avail_out == 0) ; - /* printf("RETVAL %d, avail out %d, byte %c\n", RETVAL, s->stream.avail_out, s->deflateParams_out_byte); */ + s->stream.avail_in = 0; + s->stream.next_out = &(s->deflateParams_out_byte) ; + s->stream.avail_out = 1; + RETVAL = deflateParams(&(s->stream), s->Level, s->Strategy); + s->deflateParams_out_valid = + (RETVAL == Z_OK && s->stream.avail_out == 0) ; #else - /* printf("Level %d Strategy %d, Prev Len %d\n", + /* printf("Level %d Strategy %d, Prev Len %d\n", s->Level, s->Strategy, s->deflateParams_out_length); */ - s->stream.avail_in = 0; - if (s->deflateParams_out_buffer == NULL) - s->deflateParams_out_buffer = safemalloc(deflateParams_BUFFER_SIZE); - s->stream.next_out = s->deflateParams_out_buffer ; - s->stream.avail_out = deflateParams_BUFFER_SIZE; - - RETVAL = deflateParams(&(s->stream), s->Level, s->Strategy); - s->deflateParams_out_length = deflateParams_BUFFER_SIZE - s->stream.avail_out; - /* printf("RETVAL %d, length out %d, avail %d\n", - RETVAL, s->deflateParams_out_length, s->stream.avail_out ); */ + RETVAL = flushParams(s); #endif + } + else + RETVAL = Z_OK; OUTPUT: - RETVAL + RETVAL int diff --git a/cpan/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm b/cpan/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm index 175462ff6c..4ff590087d 100644 --- a/cpan/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm +++ b/cpan/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm @@ -10,7 +10,7 @@ use warnings ; use bytes ; our ($VERSION, $XS_VERSION, @ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD, %DEFLATE_CONSTANTS, @DEFLATE_CONSTANTS); -$VERSION = '2.070'; +$VERSION = '2.074'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -1590,7 +1590,7 @@ See the Changes file. =head1 COPYRIGHT AND LICENSE -Copyright (c) 2005-2016 Paul Marquess. All rights reserved. +Copyright (c) 2005-2017 Paul Marquess. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/cpan/Compress-Raw-Zlib/t/02zlib.t b/cpan/Compress-Raw-Zlib/t/02zlib.t index 2c9aad6715..5d024a970c 100644 --- a/cpan/Compress-Raw-Zlib/t/02zlib.t +++ b/cpan/Compress-Raw-Zlib/t/02zlib.t @@ -27,7 +27,7 @@ BEGIN $count = 232 ; } elsif ($] >= 5.006) { - $count = 317 ; + $count = 320 ; } else { $count = 275 ; @@ -559,6 +559,13 @@ SKIP: is $x->get_Level(), Z_BEST_SPEED; is $x->get_Strategy(), Z_HUFFMAN_ONLY; + # change both Level & Strategy again without any calls to deflate + $status = $x->deflateParams(-Level => Z_DEFAULT_COMPRESSION, -Strategy => Z_DEFAULT_STRATEGY, -Bufsize => 1234) ; + cmp_ok $status, '==', Z_OK ; + + is $x->get_Level(), Z_DEFAULT_COMPRESSION; + is $x->get_Strategy(), Z_DEFAULT_STRATEGY; + $status = $x->deflate($goodbye, $Answer) ; cmp_ok $status, '==', Z_OK ; $input .= $goodbye; @@ -568,7 +575,7 @@ SKIP: cmp_ok $status, '==', Z_OK ; is $x->get_Level(), Z_NO_COMPRESSION; - is $x->get_Strategy(), Z_HUFFMAN_ONLY; + is $x->get_Strategy(), Z_DEFAULT_STRATEGY; $status = $x->deflate($goodbye, $Answer) ; cmp_ok $status, '==', Z_OK ; diff --git a/cpan/Compress-Raw-Zlib/t/compress/CompTestUtils.pm b/cpan/Compress-Raw-Zlib/t/compress/CompTestUtils.pm index 9815eb2caa..da238e15d2 100644 --- a/cpan/Compress-Raw-Zlib/t/compress/CompTestUtils.pm +++ b/cpan/Compress-Raw-Zlib/t/compress/CompTestUtils.pm @@ -70,8 +70,8 @@ BEGIN { our ($index); $index = '00000'; - our ($useTempFile) = defined &File::Temp::tempdir; - our ($useTempDir) = defined &File::Temp::newdir; + our ($useTempFile); + our ($useTempDir); sub new { @@ -115,7 +115,12 @@ BEGIN { # autogenerate the name if none supplied $_ = "tmpdir" . $$ . "X" . $index ++ . ".tmp" ; } - foreach (@_) { rmtree $_; mkdir $_, 0777 } + foreach (@_) + { + rmtree $_, {verbose => 0, safe => 1} + if -d $_; + mkdir $_, 0777 + } bless [ @_ ], $self ; } @@ -126,7 +131,11 @@ BEGIN { if (! $useTempFile) { my $self = shift ; - foreach (@$self) { rmtree $_ } + foreach (@$self) + { + rmtree $_, {verbose => 0, safe => 1} + if -d $_ ; + } } } } diff --git a/cpan/Compress-Raw-Zlib/zlib-src/inflate.c b/cpan/Compress-Raw-Zlib/zlib-src/inflate.c index c8dca0b08f..6047cd884f 100644 --- a/cpan/Compress-Raw-Zlib/zlib-src/inflate.c +++ b/cpan/Compress-Raw-Zlib/zlib-src/inflate.c @@ -1490,10 +1490,11 @@ int ZEXPORT inflateUndermine( if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; - state->sane = !subvert; #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + state->sane = !subvert; return Z_OK; #else + (void)subvert; state->sane = 1; return Z_DATA_ERROR; #endif @@ -1504,7 +1505,11 @@ long ZEXPORT inflateMark( { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; + /* Change to return statement below is taken from + https://github.com/madler/zlib/commit/2edb94a3025d288dc251bc6cbb2c02e60fbd7438 + */ + if (strm == Z_NULL || strm->state == Z_NULL) + return -(1L << 16); state = (struct inflate_state FAR *)strm->state; return ((long)(state->back) << 16) + (state->mode == COPY ? state->length : -- Perl5 Master Repository
