diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index dbe20d87d187..a2e7c704fa88 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -216,7 +216,7 @@ package Maintainers; }, 'Compress::Raw::Zlib' => { - 'DISTRIBUTION' => 'PMQS/Compress-Raw-Zlib-2.105.tar.gz', + 'DISTRIBUTION' => 'PMQS/Compress-Raw-Zlib-2.202.tar.gz', 'FILES' => q[cpan/Compress-Raw-Zlib], 'EXCLUDED' => [ qr{^examples/}, diff --git a/cpan/Compress-Raw-Zlib/Makefile.PL b/cpan/Compress-Raw-Zlib/Makefile.PL index bf3681babd80..299093bb81d3 100644 --- a/cpan/Compress-Raw-Zlib/Makefile.PL +++ b/cpan/Compress-Raw-Zlib/Makefile.PL @@ -12,6 +12,7 @@ use Config; my $ZLIB_LIB ; my $ZLIB_INCLUDE ; my $BUILD_ZLIB = 0 ; +my $USE_ZLIB_NG = 0; my $OLD_ZLIB = '' ; my $WALL = '' ; my $GZIP_OS_CODE = -1 ; @@ -74,6 +75,8 @@ UpDowngrade(getPerlFiles('MANIFEST')) my $OPT_Z_PREFIX = '-DZ_PREFIX' ; my $OPT_ZLIB_INCLUDE = "-I$ZLIB_INCLUDE"; my $OPT_ZLIB_LIB = "-L$ZLIB_LIB" ; +my $OPT_SOLO = '-DZ_SOLO'; +my $OPT_USE_ZLIB_NG = ""; if (! $BUILD_ZLIB) { @@ -85,13 +88,21 @@ if (! $BUILD_ZLIB) $OPT_ZLIB_LIB = '' if $ZLIB_LIB eq './zlib-src' ; + + $OPT_SOLO = ''; +} + +if ( $USE_ZLIB_NG) +{ + $OPT_USE_ZLIB_NG = '-DUSE_ZLIB_NG'; + $ZLIB_LIBRARY_NAME = $^O eq 'MSWin32' ? 'zlib-ng' : 'z-ng' ; } WriteMakefile( NAME => 'Compress::Raw::Zlib', VERSION_FROM => 'lib/Compress/Raw/Zlib.pm', INC => $OPT_ZLIB_INCLUDE , - DEFINE => "-DNO_VIZ -DZ_SOLO $OLD_ZLIB $WALL $OPT_Z_PREFIX -DGZIP_OS_CODE=$GZIP_OS_CODE $USE_PPPORT_H -DPerl_crz_BUILD_ZLIB=$BUILD_ZLIB" , + DEFINE => "-DNO_VIZ $OPT_SOLO $OLD_ZLIB $WALL $OPT_Z_PREFIX $OPT_USE_ZLIB_NG -DGZIP_OS_CODE=$GZIP_OS_CODE $USE_PPPORT_H -DPerl_crz_BUILD_ZLIB=$BUILD_ZLIB" , XS => { 'Zlib.xs' => 'Zlib.c'}, 'depend' => { 'Makefile' => 'config.in' }, 'clean' => { FILES => '*.c constants.h constants.xs' }, @@ -177,7 +188,6 @@ my @names = qw( Z_NEED_DICT Z_NO_COMPRESSION Z_NO_FLUSH - Z_NULL Z_OK Z_PARTIAL_FLUSH Z_RLE @@ -187,8 +197,13 @@ my @names = qw( Z_UNKNOWN Z_VERSION_ERROR + ZLIBNG_VERNUM + ZLIBNG_VER_MAJOR + ZLIBNG_VER_MINOR + ZLIBNG_VER_REVISION + ZLIBNG_VER_STATUS + ZLIBNG_VER_MODIFIED ); - #ZLIB_VERNUM my %verSpecificNames = ( Z_TREES => '1240', @@ -226,6 +241,9 @@ if (eval {require ExtUtils::Constant; 1}) { } keys %verSpecificNames ; + push @names, { name => 'Z_NULL', type => 'UV' }; + push @names, { name => 'ZLIBNG_VERSION', type => 'PV' }; + ExtUtils::Constant::WriteConstants( NAME => 'Zlib', NAMES => \@names, @@ -244,12 +262,24 @@ else { } } +sub getBoolean +{ + my $name = shift ; + my $info = shift; + + my $x = defined $ENV{$name} + ? $ENV{$name} + : $info->{$name} ; + + return ($x =~ /^yes|on|true|1$/i) ? 1 : 0; +} + sub ParseCONFIG { my ($k, $v) ; my @badkey = () ; my %Info = () ; - my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE ) ; + my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE USE_ZLIB_NG) ; my %ValidOption = map {$_, 1} @Options ; my %Parsed = %ValidOption ; my $CONFIG = 'config.in' ; @@ -285,44 +315,48 @@ sub ParseCONFIG $ZLIB_INCLUDE = defined $ENV{'ZLIB_INCLUDE'} ? $ENV{'ZLIB_INCLUDE'} : $Info{'INCLUDE'} ; + $ZLIB_LIB = defined $ENV{'ZLIB_LIB'} ?$ENV{'ZLIB_LIB'} : $Info{'LIB'} ; + $USE_ZLIB_NG = getBoolean('USE_ZLIB_NG', \%Info); + if ($^O eq 'VMS') { $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE); $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB); } - my $y = defined $ENV{'OLD_ZLIB'} - ? $ENV{'OLD_ZLIB'} - : $Info{'OLD_ZLIB'} ; - $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i; - - my $x = defined $ENV{'BUILD_ZLIB'} - ? $ENV{'BUILD_ZLIB'} - : $Info{'BUILD_ZLIB'} ; - - if ($x and $x =~ /^yes|on|true|1$/i ) { + $OLD_ZLIB = '-DOLD_ZLIB' + if getBoolean('OLD_ZLIB', \%Info); - $BUILD_ZLIB = 1 ; + $BUILD_ZLIB = getBoolean('BUILD_ZLIB', \%Info); - # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when - # BUILD_ZLIB is specified. - die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n" - if $ZLIB_LIB ne $ZLIB_INCLUDE ; + if ($BUILD_ZLIB ) { - # Check the zlib source directory exists - die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n" - unless -d $ZLIB_LIB ; + # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when + # BUILD_ZLIB is specified. + die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n" + if $ZLIB_LIB ne $ZLIB_INCLUDE ; - # check for a well known file - die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n" - unless -e catfile($ZLIB_LIB, 'zlib.h') ; + # Check the zlib source directory exists + die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n" + unless -d $ZLIB_LIB ; + # check for a well known file + if ($USE_ZLIB_NG) + { + die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib-ng source files\n" + unless -e catfile($ZLIB_LIB, 'zlib-ng.h') ; + } + else + { + die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n" + unless -e catfile($ZLIB_LIB, 'zlib.h') ; + } - # write the Makefile - print "Building Zlib enabled\n" ; + # write the Makefile + print "Building Zlib enabled\n" ; } $GZIP_OS_CODE = defined $ENV{'GZIP_OS_CODE'} @@ -348,6 +382,7 @@ sub ParseCONFIG GZIP_OS_CODE [$GZIP_OS_CODE] OLD_ZLIB [$OLD_ZLIB] BUILD_ZLIB [$BUILD_ZLIB] + USE_ZLIB_NG [$USE_ZLIB_NG] EOM diff --git a/cpan/Compress-Raw-Zlib/Zlib.xs b/cpan/Compress-Raw-Zlib/Zlib.xs index cb7f0e0e1e57..f9bb891d47fb 100644 --- a/cpan/Compress-Raw-Zlib/Zlib.xs +++ b/cpan/Compress-Raw-Zlib/Zlib.xs @@ -31,53 +31,184 @@ #include "perl.h" #include "XSUB.h" -#include "zlib.h" +#if USE_ZLIB_NG +# include "zlib-ng.h" +#else +# include "zlib.h" +#endif + /* zlib prior to 1.06 doesn't know about z_off_t */ #ifndef z_off_t # define z_off_t long #endif -#if ! defined(ZLIB_VERNUM) || ZLIB_VERNUM < 0x1200 +#if ! USE_ZLIB_NG && (! defined(ZLIB_VERNUM) || ZLIB_VERNUM < 0x1200) # define NEED_DUMMY_BYTE_AT_END #endif -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1210 +#if USE_ZLIB_NG || (defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1210) # define MAGIC_APPEND # define AT_LEAST_ZLIB_1_2_1 #endif -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1221 +#if USE_ZLIB_NG || (defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1221) # define AT_LEAST_ZLIB_1_2_2_1 #endif -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1222 +#if USE_ZLIB_NG || (defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1222) # define AT_LEAST_ZLIB_1_2_2_2 #endif -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1223 +#if USE_ZLIB_NG || (defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1223) # define AT_LEAST_ZLIB_1_2_2_3 #endif -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230 +#if USE_ZLIB_NG || (defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230) # define AT_LEAST_ZLIB_1_2_3 #endif -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1252 +#if USE_ZLIB_NG || (defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1252) /* Use Z_SOLO to build source means need own malloc/free */ # define AT_LEAST_ZLIB_1_2_5_2 #endif -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1280 -# define AT_LEAST_ZLIB_1_2_8 -#endif -#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1290 -# define AT_LEAST_ZLIB_1_2_9 +/* zlib vs zlib-ng */ + +#if USE_ZLIB_NG + +/* zlibng native */ + +# define HAVE_ZLIB_NG_NATIVE TRUE +# define HAVE_ZLIB_NG_COMPAT FALSE + +# ifndef ZLIBNG_VER_STATUS +# define ZLIBNG_VER_STATUS 0 +# endif + +# ifndef ZLIBNG_VER_MODIFIED +# define ZLIBNG_VER_MODIFIED 0 +# endif + +# define CRZ_adlerInitial zng_adler32(0L, Z_NULL, 0) +# define CRZ_crcInitial zng_crc32(0L, Z_NULL, 0) + +# define CRZ_ZSTREAM zng_stream + + + +# define CRZ_adler32 zng_adler32 +# define CRZ_adler32_combine zng_adler32_combine +# define CRZ_crc32 zng_crc32 +# define CRZ_crc32_combine zng_crc32_combine +# define CRZ_deflate zng_deflate +# define CRZ_deflateEnd zng_deflateEnd +# define CRZ_deflateInit zng_deflateInit +# define CRZ_deflateInit2 zng_deflateInit2 +# define CRZ_deflateParams zng_deflateParams +# define CRZ_deflatePrime zng_deflatePrime +# define CRZ_deflateReset zng_deflateReset +# define CRZ_deflateSetDictionary zng_deflateSetDictionary +# define CRZ_deflateTune zng_deflateTune +# define CRZ_inflate zng_inflate +# define CRZ_inflateEnd zng_inflateEnd +# define CRZ_inflateInit2 zng_inflateInit2 +# define CRZ_inflateReset zng_inflateReset +# define CRZ_inflateSetDictionary zng_inflateSetDictionary +# define CRZ_inflateSync zng_inflateSync +# define CRZ_zlibCompileFlags zng_zlibCompileFlags + + +/* zlib symbols & functions */ + +// # define CRZ_ZLIB_VERSION ZLIBNG_VERSION +// # define ZLIB_VERSION ZLIBNG_VERSION +# define CRZ_ZLIB_VERSION "" +# define ZLIB_VERSION "" + +// # define CRZ_zlibVersion zlibng_version +// # define CRZ_zlib_version zlibng_version + + const char *CRZ_zlibVersion(void) { return ""; } + const char *CRZ_zlib_version(void) { return ""; } + + +#else /* zlib specific */ + + +# define HAVE_ZLIB_NG_NATIVE FALSE + +/* Is this real zlib or zlib-ng in compat mode */ +# ifdef ZLIBNG_VERSION + /* zlib-ng in compat mode */ +# define HAVE_ZLIB_NG_COMPAT TRUE + +# ifndef ZLIBNG_VER_STATUS +# define ZLIBNG_VER_STATUS 0 +# endif + +# ifndef ZLIBNG_VER_MODIFIED +# define ZLIBNG_VER_MODIFIED 0 +# endif + + const char *zlibng_version(void) { return ZLIBNG_VERSION ; } + + +# else + /* zlib native mode */ + +# define HAVE_ZLIB_NG_COMPAT FALSE + + /* zlib doesn't have the ZLIBNG synbols, so create them */ +# define ZLIBNG_VERSION "" +# define ZLIBNG_VERNUM 0 +# define ZLIBNG_VER_MAJOR 0 +# define ZLIBNG_VER_MINOR 0 +# define ZLIBNG_VER_REVISION 0 +# define ZLIBNG_VER_STATUS 0 +# define ZLIBNG_VER_MODIFIED 0 +# define ZLIBNG_VERNUM 0 + + const char *zlibng_version(void) { return ""; } + +# endif + + + +# define CRZ_adlerInitial adler32(0L, Z_NULL, 0) +# define CRZ_crcInitial crc32(0L, Z_NULL, 0) + +# define CRZ_ZSTREAM z_stream + +# define CRZ_adler32 adler32 +# define CRZ_adler32_combine adler32_combine +# define CRZ_crc32 crc32 +# define CRZ_crc32_combine crc32_combine +# define CRZ_deflate deflate +# define CRZ_deflateEnd deflateEnd +# define CRZ_deflateInit deflateInit +# define CRZ_deflateInit2 deflateInit2 +# define CRZ_deflateParams deflateParams +# define CRZ_deflatePrime deflatePrime +# define CRZ_deflateReset deflateReset +# define CRZ_deflateSetDictionary deflateSetDictionary +# define CRZ_deflateTune deflateTune +# define CRZ_inflate inflate +# define CRZ_inflateEnd inflateEnd +# define CRZ_inflateInit2 inflateInit2 +# define CRZ_inflateReset inflateReset +# define CRZ_inflateSetDictionary inflateSetDictionary +# define CRZ_inflateSync inflateSync +# define CRZ_zlibCompileFlags zlibCompileFlags +# define CRZ_zlibVersion zlibVersion +# define CRZ_zlib_version zlibVersion + #endif + #ifdef USE_PPPORT_H # define NEED_sv_2pvbyte # define NEED_sv_2pv_nolen @@ -132,8 +263,8 @@ typedef struct di_stream { #define FLAG_LIMIT_OUTPUT 16 uLong crc32 ; uLong adler32 ; - z_stream stream; - uLong bufsize; + CRZ_ZSTREAM stream; + uLong bufsize; SV * dictionary ; uLong dict_adler ; int last_error ; @@ -252,8 +383,6 @@ typedef di_stream * Compress__Raw__Zlib__inflateScanStream ; # define GZIP_OS_CODE OS_CODE #endif -#define adlerInitial adler32(0L, Z_NULL, 0) -#define crcInitial crc32(0L, Z_NULL, 0) /* static const char * const my_z_errmsg[] = { */ static const char my_z_errmsg[][32] = { @@ -410,10 +539,10 @@ rotate(list, len, rot) static void #ifdef CAN_PROTOTYPE -DispHex(void * ptr, int length) +DispHex(const void * ptr, int length) #else DispHex(ptr, length) - void * ptr; + const void * ptr; int length; #endif { @@ -478,7 +607,11 @@ DispStream(s, message) printf(" avail_out %lu\n", (unsigned long)s->stream.avail_out); printf(" total_in %ld\n", s->stream.total_in); printf(" total_out %ld\n", s->stream.total_out); +#if ! USE_ZLIB_NG printf(" adler %ld\n", s->stream.adler ); +#else + printf(" adler %u\n", s->stream.adler ); +#endif printf(" bufsize %ld\n", s->bufsize); printf(" dictionary %p\n", s->dictionary); printf(" dict_adler 0x%ld\n",s->dict_adler); @@ -557,9 +690,9 @@ PostInitStream(s, flags, bufsize, windowBits) s->flags = flags ; s->zip_mode = (windowBits < 0) ; if (flags & FLAG_CRC32) - s->crc32 = crcInitial ; + s->crc32 = CRZ_crcInitial ; if (flags & FLAG_ADLER32) - s->adler32 = adlerInitial ; + s->adler32 = CRZ_adlerInitial ; } @@ -648,7 +781,7 @@ flushToBuffer(di_stream* s, int flush) { dTHX; int ret ; - z_stream * strm = &s->stream; + CRZ_ZSTREAM * strm = &s->stream; Bytef* output = s->deflateParams_out_buffer ; @@ -695,7 +828,7 @@ flushParams(di_stream* s) { dTHX; int ret ; - z_stream * strm = &s->stream; + CRZ_ZSTREAM * strm = &s->stream; Bytef* output = s->deflateParams_out_buffer ; uLong total_output = s->deflateParams_out_length; @@ -715,7 +848,7 @@ flushParams(di_stream* s) strm->next_out = output + total_output; strm->avail_out = s->bufsize; - ret = deflateParams(&(s->stream), s->Level, s->Strategy); + ret = CRZ_deflateParams(&(s->stream), s->Level, s->Strategy); /* fprintf(stderr, "deflateParams %d %s %lu\n", ret, GetErrorString(ret), s->bufsize - strm->avail_out); */ @@ -750,9 +883,11 @@ PROTOTYPES: DISABLE INCLUDE: constants.xs BOOT: +#if ! USE_ZLIB_NG /* Check this version of zlib is == 1 */ - if (zlibVersion()[0] != '1') - croak("Compress::Raw::Zlib needs zlib version 1.x\n") ; + if (CRZ_zlibVersion()[0] != '1') + croak("Compress::Raw::Zlib needs zlib version 1.x\n") ; +#endif { /* Create the $os_code scalar */ @@ -766,40 +901,62 @@ BOOT: sv_setiv(os_code_sv, Perl_crz_BUILD_ZLIB) ; } - -#define Zip_zlib_version() (const char*)zlib_version +#define Zip_zlib_version() (const char*)CRZ_zlib_version() const char* Zip_zlib_version() +const char* +zlibng_version() + +#define Zip_is_zlib_native() (! (HAVE_ZLIB_NG_NATIVE || HAVE_ZLIB_NG_COMPAT)) +bool +Zip_is_zlib_native() + +#define Zip_is_zlibng_native() (bool)HAVE_ZLIB_NG_NATIVE +bool +Zip_is_zlibng_native() + +#define Zip_is_zlibng_compat() (bool)HAVE_ZLIB_NG_COMPAT +bool +Zip_is_zlibng_compat() + +#define Zip_is_zlibng() (bool)(HAVE_ZLIB_NG_NATIVE || HAVE_ZLIB_NG_COMPAT) +bool +Zip_is_zlibng() + unsigned ZLIB_VERNUM() CODE: #ifdef ZLIB_VERNUM RETVAL = ZLIB_VERNUM ; +#elif USE_ZLIB_NG + RETVAL = 0 ; #else /* 1.1.4 => 0x1140 */ - RETVAL = (ZLIB_VERSION[0] - '0') << 12 ; - RETVAL += (ZLIB_VERSION[2] - '0') << 8 ; - RETVAL += (ZLIB_VERSION[4] - '0') << 4 ; - if (strlen(ZLIB_VERSION) > 5) - RETVAL += (ZLIB_VERSION[6] - '0') ; + RETVAL = (CRZ_ZLIB_VERSION[0] - '0') << 12 ; + RETVAL += (CRZ_ZLIB_VERSION[2] - '0') << 8 ; + RETVAL += (CRZ_ZLIB_VERSION[4] - '0') << 4 ; + if (strlen(CRZ_ZLIB_VERSION) > 5) + RETVAL += (CRZ_ZLIB_VERSION[6] - '0') ; #endif OUTPUT: RETVAL #ifndef AT_LEAST_ZLIB_1_2_1 -#define zlibCompileFlags() 0 +# define Zip_zlibCompileFlags 0 +#else +# define Zip_zlibCompileFlags CRZ_zlibCompileFlags #endif uLong -zlibCompileFlags() +Zip_zlibCompileFlags() MODULE = Compress::Raw::Zlib PACKAGE = Compress::Raw::Zlib PREFIX = Zip_ -#define Zip_adler32(buf, adler) adler32(adler, buf, (uInt)len) +#define Zip_adler32(buf, adler) CRZ_adler32(adler, buf, (uInt)len) uLong -Zip_adler32(buf, adler=adlerInitial) +Zip_adler32(buf, adler=CRZ_adlerInitial) uLong adler = NO_INIT STRLEN len = NO_INIT Bytef * buf = NO_INIT @@ -814,18 +971,18 @@ Zip_adler32(buf, adler=adlerInitial) buf = (Byte*)SvPVbyte(sv, len) ; if (items < 2) - adler = adlerInitial; + adler = CRZ_adlerInitial; else if (SvOK(ST(1))) adler = SvUV(ST(1)) ; else - adler = adlerInitial; + adler = CRZ_adlerInitial; OUTPUT: RETVAL -#define Zip_crc32(buf, crc, offset) crc32(crc, buf+offset, (uInt)len-offset) +#define Zip_crc32(buf, crc, offset) CRZ_crc32(crc, buf+offset, (uInt)len-offset) uLong -Zip_crc32(buf, crc=crcInitial, offset=0) +Zip_crc32(buf, crc=CRZ_crcInitial, offset=0) uLong crc = NO_INIT STRLEN len = NO_INIT Bytef * buf = NO_INIT @@ -844,11 +1001,11 @@ Zip_crc32(buf, crc=crcInitial, offset=0) croak("Offset out of range in Compress::Raw::Zlib::crc32"); if (items < 2) - crc = crcInitial; + crc = CRZ_crcInitial; else if (SvOK(ST(1))) crc = SvUV(ST(1)) ; else - crc = crcInitial; + crc = CRZ_crcInitial; uLong crc32_combine(crc1, crc2, len2) @@ -860,7 +1017,7 @@ crc32_combine(crc1, crc2, len2) crc1 = crc1; crc2 = crc2 ; len2 = len2; /* Silence -Wall */ croak("crc32_combine needs zlib 1.2.3 or better"); #else - RETVAL = crc32_combine(crc1, crc2, len2); + RETVAL = CRZ_crc32_combine(crc1, crc2, len2); #endif OUTPUT: RETVAL @@ -876,7 +1033,7 @@ adler32_combine(adler1, adler2, len2) adler1 = adler1; adler2 = adler2 ; len2 = len2; /* Silence -Wall */ croak("adler32_combine needs zlib 1.2.3 or better"); #else - RETVAL = adler32_combine(adler1, adler2, len2); + RETVAL = CRZ_adler32_combine(adler1, adler2, len2); #endif OUTPUT: RETVAL @@ -909,7 +1066,7 @@ _deflateInit(flags,level, method, windowBits, memLevel, strategy, bufsize, dicti s->MemLevel = memLevel; s->Strategy = strategy; - err = deflateInit2(&(s->stream), level, + err = CRZ_deflateInit2(&(s->stream), level, method, windowBits, memLevel, strategy); if (trace) { @@ -924,7 +1081,7 @@ _deflateInit(flags,level, method, windowBits, memLevel, strategy, bufsize, dicti if (DO_UTF8(dictionary) && !sv_utf8_downgrade(dictionary, 1)) croak("Wide character in Compress::Raw::Zlib::Deflate::new dicrionary parameter"); #endif - err = deflateSetDictionary(&(s->stream), (const Bytef*) SvPVX(dictionary), SvCUR(dictionary)) ; + err = CRZ_deflateSetDictionary(&(s->stream), (const Bytef*) SvPVX(dictionary), SvCUR(dictionary)) ; if (trace) warn("deflateSetDictionary returned %d\n", err); s->dict_adler = s->stream.adler ; @@ -975,7 +1132,7 @@ _inflateInit(flags, windowBits, bufsize, dictionary) s->WindowBits = windowBits; - err = inflateInit2(&(s->stream), windowBits); + err = CRZ_inflateInit2(&(s->stream), windowBits); if (err != Z_OK) { Safefree(s) ; s = NULL ; @@ -986,7 +1143,7 @@ _inflateInit(flags, windowBits, bufsize, dictionary) if (s->WindowBits < 0) { STRLEN dlen; const Bytef* b = (const Bytef*)SvPVbyte(dictionary, dlen); - err = inflateSetDictionary(&(s->stream), + err = CRZ_inflateSetDictionary(&(s->stream), b, dlen); if (err != Z_OK) { Safefree(s) ; @@ -1038,7 +1195,7 @@ DualType deflateReset(s) Compress::Raw::Zlib::deflateStream s CODE: - RETVAL = deflateReset(&(s->stream)) ; + RETVAL = CRZ_deflateReset(&(s->stream)) ; if (RETVAL == Z_OK) { PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ; } @@ -1071,10 +1228,10 @@ deflate (s, buf, output) s->stream.avail_in = origlen; if (s->flags & FLAG_CRC32) - s->crc32 = crc32(s->crc32, s->stream.next_in, s->stream.avail_in) ; + s->crc32 = CRZ_crc32(s->crc32, s->stream.next_in, s->stream.avail_in) ; if (s->flags & FLAG_ADLER32) - s->adler32 = adler32(s->adler32, s->stream.next_in, s->stream.avail_in) ; + s->adler32 = CRZ_adler32(s->adler32, s->stream.next_in, s->stream.avail_in) ; /* and retrieve the output buffer */ output = deRef_l(output, "deflate") ; @@ -1143,7 +1300,7 @@ deflate (s, buf, output) /* Perl_sv_dump(output); */ } - RETVAL = deflate(&(s->stream), Z_NO_FLUSH); + RETVAL = CRZ_deflate(&(s->stream), Z_NO_FLUSH); /* if (RETVAL != Z_STREAM_ERROR) { int done = increment - s->stream.avail_out ; @@ -1181,7 +1338,7 @@ DESTROY(s) CODE: if (trace) printf("Compress::Raw::Zlib::deflateStream::DESTROY %p\n", s); - deflateEnd(&s->stream) ; + CRZ_deflateEnd(&s->stream) ; if (s->dictionary) SvREFCNT_dec(s->dictionary) ; #ifndef SETP_BYTE @@ -1273,7 +1430,7 @@ flush(s, output, f=Z_FINISH) /* Perl_sv_dump(output); */ } - RETVAL = deflate(&(s->stream), f); + RETVAL = CRZ_deflate(&(s->stream), f); /* if (RETVAL != Z_STREAM_ERROR) { int done = availableout - s->stream.avail_out ; @@ -1449,7 +1606,7 @@ char* msg(s) Compress::Raw::Zlib::deflateStream s CODE: - RETVAL = s->stream.msg; + RETVAL = (char*)s->stream.msg; OUTPUT: RETVAL @@ -1466,7 +1623,7 @@ deflateTune(s, good_length, max_lazy, nice_length, max_chain) nice_length = nice_length; max_chain = max_chain; /* Silence -Wall */ croak("deflateTune needs zlib 1.2.2.3 or better"); #else - RETVAL = deflateTune(&(s->stream), good_length, max_lazy, nice_length, max_chain); + RETVAL = CRZ_deflateTune(&(s->stream), good_length, max_lazy, nice_length, max_chain); #endif OUTPUT: RETVAL @@ -1483,7 +1640,7 @@ DualType inflateReset(s) Compress::Raw::Zlib::inflateStream s CODE: - RETVAL = inflateReset(&(s->stream)) ; + RETVAL = CRZ_inflateReset(&(s->stream)) ; if (RETVAL == Z_OK) { PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ; } @@ -1582,7 +1739,7 @@ inflate (s, buf, output, eof=FALSE) s->stream.avail_out); DispStream(s, "BEFORE"); Perl_sv_dump(output); */ - RETVAL = inflate(&(s->stream), Z_SYNC_FLUSH); + RETVAL = CRZ_inflate(&(s->stream), Z_SYNC_FLUSH); /* printf("INFLATE returned %d %s, avail in %d, out %d\n", RETVAL, GetErrorString(RETVAL), s->stream.avail_in, s->stream.avail_out); */ @@ -1591,7 +1748,7 @@ Perl_sv_dump(output); */ STRLEN dlen; const Bytef* b = (const Bytef*)SvPV(s->dictionary, dlen) ; s->dict_adler = s->stream.adler ; - RETVAL = inflateSetDictionary(&(s->stream), + RETVAL = CRZ_inflateSetDictionary(&(s->stream), b, dlen); if (RETVAL == Z_OK) continue; @@ -1621,8 +1778,8 @@ Perl_sv_dump(output); */ } } #ifdef NEED_DUMMY_BYTE_AT_END - if (eof && RETVAL == Z_OK && s->flags & FLAG_LIMIT_OUTPUT == 0) { - Bytef* nextIn = s->stream.next_in; + if (eof && RETVAL == Z_OK && (s->flags & FLAG_LIMIT_OUTPUT) == 0) { + Bytef* nextIn = (Bytef*)s->stream.next_in; uInt availIn = s->stream.avail_in; s->stream.next_in = (Bytef*) " "; s->stream.avail_in = 1; @@ -1635,7 +1792,7 @@ Perl_sv_dump(output); */ s->stream.avail_out = increment; bufinc *= 2 ; } - RETVAL = inflate(&(s->stream), Z_SYNC_FLUSH); + RETVAL = CRZ_inflate(&(s->stream), Z_SYNC_FLUSH); s->stream.next_in = nextIn ; s->stream.avail_in = availIn ; } @@ -1661,12 +1818,12 @@ Perl_sv_dump(output); */ SvSETMAGIC(output); if (s->flags & FLAG_CRC32 ) - s->crc32 = crc32(s->crc32, + s->crc32 = CRZ_crc32(s->crc32, (const Bytef*)SvPVX(output)+prefix_length, SvCUR(output)-prefix_length) ; if (s->flags & FLAG_ADLER32) - s->adler32 = adler32(s->adler32, + s->adler32 = CRZ_adler32(s->adler32, (const Bytef*)SvPVX(output)+prefix_length, SvCUR(output)-prefix_length) ; @@ -1730,7 +1887,7 @@ inflateSync (s, buf) s->stream.next_out = (Bytef*) NULL; s->stream.avail_out = 0; - RETVAL = inflateSync(&(s->stream)); + RETVAL = CRZ_inflateSync(&(s->stream)); s->last_error = RETVAL ; /* fix the input buffer */ @@ -1749,7 +1906,7 @@ void DESTROY(s) Compress::Raw::Zlib::inflateStream s CODE: - inflateEnd(&s->stream) ; + CRZ_inflateEnd(&s->stream) ; if (s->dictionary) SvREFCNT_dec(s->dictionary) ; #ifndef SETP_BYTE @@ -1815,7 +1972,7 @@ char* msg(s) Compress::Raw::Zlib::inflateStream s CODE: - RETVAL = s->stream.msg; + RETVAL = (char*)s->stream.msg; OUTPUT: RETVAL @@ -1847,7 +2004,7 @@ void DESTROY(s) Compress::Raw::Zlib::inflateScanStream s CODE: - inflateEnd(&s->stream) ; + CRZ_inflateEnd(&s->stream) ; if (s->dictionary) SvREFCNT_dec(s->dictionary) ; #ifndef SETP_BYTE @@ -1869,7 +2026,7 @@ DualType inflateReset(s) Compress::Raw::Zlib::inflateScanStream s CODE: - RETVAL = inflateReset(&(s->stream)) ; + RETVAL = CRZ_inflateReset(&(s->stream)) ; if (RETVAL == Z_OK) { PostInitStream(s, s->flags, s->bufsize, s->WindowBits) ; } @@ -1916,7 +2073,7 @@ scan(s, buf, out=NULL, eof=FALSE) /* DispStream(s, "before inflate\n"); */ /* inflate and check for errors */ - RETVAL = inflate(&(s->stream), Z_BLOCK); + RETVAL = CRZ_inflate(&(s->stream), Z_BLOCK); if (start_len > 1 && ! eof_mode) s->window_lastByte = *(s->stream.next_in - 1 ) ; @@ -1926,11 +2083,11 @@ scan(s, buf, out=NULL, eof=FALSE) break ; if (s->flags & FLAG_CRC32 ) - s->crc32 = crc32(s->crc32, s->window + s->window_have, + s->crc32 = CRZ_crc32(s->crc32, s->window + s->window_have, WINDOW_SIZE - s->window_have - s->stream.avail_out); if (s->flags & FLAG_ADLER32) - s->adler32 = adler32(s->adler32, s->window + s->window_have, + s->adler32 = CRZ_adler32(s->adler32, s->window + s->window_have, WINDOW_SIZE - s->window_have - s->stream.avail_out); s->uncompressedBytes = @@ -2107,11 +2264,11 @@ _createDeflateStream(inf_s, flags,level, method, windowBits, memLevel, strategy, s->MemLevel = memLevel; s->Strategy = strategy; - err = deflateInit2(&(s->stream), level, + err = CRZ_deflateInit2(&(s->stream), level, method, windowBits, memLevel, strategy); if (err == Z_OK) { - err = deflateSetDictionary(&(s->stream), inf_s->window, inf_s->window_have); + err = CRZ_deflateSetDictionary(&(s->stream), inf_s->window, inf_s->window_have); s->dict_adler = s->stream.adler ; } @@ -2128,7 +2285,7 @@ _createDeflateStream(inf_s, flags,level, method, windowBits, memLevel, strategy, s->stream.total_in = inf_s->stream.total_out ; if (inf_s->window_left) { /* printf("** window_left %d, window_lastByte %d\n", inf_s->window_left, inf_s->window_lastByte); */ - deflatePrime(&(s->stream), 8 - inf_s->window_left, inf_s->window_lastByte); + CRZ_deflatePrime(&(s->stream), 8 - inf_s->window_left, inf_s->window_lastByte); } } } diff --git a/cpan/Compress-Raw-Zlib/config.in b/cpan/Compress-Raw-Zlib/config.in index fa998b53dbb8..b82e0b53ff33 100644 --- a/cpan/Compress-Raw-Zlib/config.in +++ b/cpan/Compress-Raw-Zlib/config.in @@ -21,6 +21,7 @@ INCLUDE = ./zlib-src LIB = ./zlib-src OLD_ZLIB = False GZIP_OS_CODE = AUTO_DETECT +USE_ZLIB_NG = False # end of file config.in diff --git a/cpan/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm b/cpan/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm index 004a541f75b8..7e403ba1e3b9 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.105'; +$VERSION = '2.202'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -96,6 +96,14 @@ $VERSION = eval $VERSION; Z_UNKNOWN Z_VERSION_ERROR + ZLIBNG_VERSION + ZLIBNG_VERNUM + ZLIBNG_VER_MAJOR + ZLIBNG_VER_MINOR + ZLIBNG_VER_REVISION + ZLIBNG_VER_STATUS + ZLIBNG_VER_MODIFIED + WANT_GZIP WANT_GZIP_OR_ZLIB ); @@ -598,7 +606,7 @@ __END__ =head1 NAME -Compress::Raw::Zlib - Low-Level Interface to zlib compression library +Compress::Raw::Zlib - Low-Level Interface to zlib or zlib-ng compression library =head1 SYNOPSIS @@ -641,11 +649,18 @@ Compress::Raw::Zlib - Low-Level Interface to zlib compression library my $version = Compress::Raw::Zlib::zlib_version(); my $flags = Compress::Raw::Zlib::zlibCompileFlags(); + is_zlib_native(); + is_zlibng_native(); + is_zlibng_compat(); + is_zlibng(); + =head1 DESCRIPTION -The I module provides a Perl interface to the I -compression library (see L for details about where to get -I). +The I module provides a Perl interface to the I or I +compression libraries (see L for details about where to get +I or I). + +In the text below all references to I are also applicable to I unless otherwise stated. =head1 Compress::Raw::Zlib::Deflate @@ -1300,12 +1315,20 @@ Refer to the I documentation for more details. =head2 my $version = Compress::Raw::Zlib::zlib_version(); -Returns the version of the zlib library. +Returns the version of the I library if this module has been built with the I library. +If this module has been built with I in native mode, this function will return a empty string. +If this module has been built with I in compat mode, this function will return the Izlib> API +verion that I is supporting. + +=head2 my $version = Compress::Raw::Zlib::zlibng_version(); + +Returns the version of the zlib-ng library if this module has been built with the I library. +If this module has been built with I, this function will return a empty string. =head2 my $flags = Compress::Raw::Zlib::zlibCompileFlags(); Returns the flags indicating compile-time options that were used to build -the zlib library. See the zlib documentation for a description of the flags +the zlib or zlib-ng library. See the zlib documentation for a description of the flags returned by C. Note that when the zlib sources are built along with this module the @@ -1313,6 +1336,21 @@ C flags (bits 24, 25 and 26) should be ignored. If you are using zlib 1.2.0 or older, C will return 0. +=head2 is_zlib_native(); +=head2 is_zlibng_native(); +=head2 is_zlibng_compat(); +=head2 is_zlibng(); + +These function can use used to check if C was been built with I or I. + +The function C returns true if C was built with I. +The function C returns true if C was built with I. + +The I library has an option to build with a zlib-compataible API. +The c function retuens true if zlib-ng has ben built with this API. + +Finally, C returns true if I was built with its native API. + =head1 The LimitOutput option. By default C<< $i->inflate($input, $output) >> will uncompress I data @@ -1584,6 +1622,9 @@ C and Mark Adler C. The primary site for the I compression library is L. +The primary site for the I compression library is +L. + The primary site for gzip is L. =head1 AUTHOR diff --git a/cpan/Compress-Raw-Zlib/t/01version.t b/cpan/Compress-Raw-Zlib/t/01version.t index a6429f5d41aa..e6300b5e7b27 100644 --- a/cpan/Compress-Raw-Zlib/t/01version.t +++ b/cpan/Compress-Raw-Zlib/t/01version.t @@ -18,103 +18,79 @@ BEGIN $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 2 + $extra ; + plan tests => 9 + $extra ; use_ok('Compress::Raw::Zlib', 2) ; } -sub bit -{ - return 1 << $_[0]; -} - -{ +use CompTestUtils; - my $zlib_h = ZLIB_VERSION ; - my $libz = Compress::Raw::Zlib::zlib_version; - my $ZLIB_VERNUM = sprintf ("0x%X", Compress::Raw::Zlib::ZLIB_VERNUM()) ; - my $flags = Compress::Raw::Zlib::zlibCompileFlags(); - - my %sizes = ( - 0 => '16 bit', - 1 => '32 bit', - 2 => '64 bit', - 3 => 'other' - ); - my $uIntSize = $sizes{ ($flags >> 0) & 0x3 }; - my $uLongSize = $sizes{ ($flags >> 2) & 0x3 }; - my $pointerSize = $sizes{ ($flags >> 4) & 0x3 }; - my $zOffSize = $sizes{ ($flags >> 6) & 0x3 }; - - my @compiler_options; - push @compiler_options, 'ZLIB_DEBUG' if $flags & bit(8) ; - push @compiler_options, 'ASM' if $flags & bit(9) ; - push @compiler_options, 'ZLIB_WINAPI' if $flags & bit(10) ; - push @compiler_options, 'None' unless @compiler_options; - my $compiler_options = join ", ", @compiler_options; - - my @one_time; - push @one_time, 'BUILDFIXED' if $flags & bit(12) ; - push @one_time, 'DYNAMIC_CRC_TABLE' if $flags & bit(13) ; - push @one_time, 'None' unless @one_time; - my $one_time = join ", ", @one_time; - - my @library; - push @library, 'NO_GZCOMPRESS' if $flags & bit(16) ; - push @library, 'NO_GZIP' if $flags & bit(17) ; - push @library, 'None' unless @library; - my $library = join ", ", @library; - - my @operational; - push @operational, 'PKZIP_BUG_WORKAROUND' if $flags & bit(20) ; - push @operational, 'FASTEST' if $flags & bit(21) ; - push @operational, 'None' unless @operational; - my $operational = join ", ", @operational; - - diag < '1.2.11.zlib-ng', + '2.0.1' => '1.2.11.zlib-ng', + '2.0.2' => '1.2.11.zlib-ng', + '2.0.3' => '1.2.11.zlib-ng', + '2.0.4' => '1.2.11.zlib-ng', + '2.0.5' => '1.2.11.zlib-ng', + '2.0.6' => '1.2.11.zlib-ng', + ); + + my $zv = Compress::Raw::Zlib::zlibng_version(); + + my $compat_ver = $zlibng2zlib{$expected_version}; + + is substr($zv, 0, length($expected_version)), $expected_version, "Expected Version is $expected_version"; + ok ! Compress::Raw::Zlib::is_zlib_native(), "! is_zlib_native"; + ok Compress::Raw::Zlib::is_zlibng(), "is_zlibng"; + ok ! Compress::Raw::Zlib::is_zlibng_native(), "! is_zlibng_native"; + ok Compress::Raw::Zlib::is_zlibng_compat(), "is_zlibng_compat"; + is Compress::Raw::Zlib::zlib_version(), $compat_ver, "zlib_version() should be $compat_ver"; + is Compress::Raw::Zlib::ZLIB_VERSION, $compat_ver, "ZLIB_VERSION should be $compat_ver"; + } + else + { + # zlib native + my $zv = Compress::Raw::Zlib::zlib_version(); + is substr($zv, 0, length($expected_version)), $expected_version, "Expected Version is $expected_version"; + ok Compress::Raw::Zlib::is_zlib_native(), "is_zlib_native"; + ok ! Compress::Raw::Zlib::is_zlibng(), "! is_zlibng"; + ok ! Compress::Raw::Zlib::is_zlibng_native(), "! is_zlibng_native"; + ok ! Compress::Raw::Zlib::is_zlibng_compat(), "! is_zlibng_compat"; + is Compress::Raw::Zlib::zlibng_version(), '', "zlibng_version() should be empty"; + is Compress::Raw::Zlib::ZLIBNG_VERSION, '', "ZLIBNG_VERSION should be empty"; } -You probably have two versions of zlib installed on your system. -Try removing the one you don't want to use and rebuild. -EOM } diff --git a/cpan/Compress-Raw-Zlib/t/02zlib.t b/cpan/Compress-Raw-Zlib/t/02zlib.t index 38124a53d367..292538b7ddf2 100644 --- a/cpan/Compress-Raw-Zlib/t/02zlib.t +++ b/cpan/Compress-Raw-Zlib/t/02zlib.t @@ -11,7 +11,6 @@ use warnings; use bytes; use Test::More ; -use CompTestUtils; use constant ZLIB_1_2_12_0 => 0x12C0; @@ -39,6 +38,8 @@ BEGIN use_ok('Compress::Raw::Zlib', 2) ; } +use CompTestUtils; + my $Zlib_ver = Compress::Raw::Zlib::zlib_version ; @@ -50,12 +51,7 @@ EOM my $len = length $hello ; # Check zlib_version and ZLIB_VERSION are the same. -SKIP: { - skip "TEST_SKIP_VERSION_CHECK is set", 1 - if $ENV{TEST_SKIP_VERSION_CHECK}; - is Compress::Raw::Zlib::zlib_version, ZLIB_VERSION, - "ZLIB_VERSION matches Compress::Raw::Zlib::zlib_version" ; -} +test_zlib_header_matches_library(); { title "Error Cases" ; @@ -492,7 +488,8 @@ SKIP: } # Z_STREAM_END returned by 1.12.2, Z_DATA_ERROR for older zlib - if (ZLIB_VERNUM >= ZLIB_1_2_12_0) + # ZLIB_NG has the fix for all versions + if (ZLIB_VERNUM >= ZLIB_1_2_12_0 || Compress::Raw::Zlib::is_zlibng) { cmp_ok $status, '==', Z_STREAM_END ; } @@ -526,7 +523,7 @@ SKIP: $GOT = ''; $status = $k->inflate($rest, $GOT); # Z_STREAM_END returned by 1.12.2, Z_DATA_ERROR for older zlib - if (ZLIB_VERNUM >= ZLIB_1_2_12_0 ) + if (ZLIB_VERNUM >= ZLIB_1_2_12_0 || Compress::Raw::Zlib::is_zlibng) { cmp_ok $status, '==', Z_STREAM_END ; } @@ -1023,7 +1020,7 @@ SKIP: my $flags = Compress::Raw::Zlib::zlibCompileFlags; - if (ZLIB_VERNUM() < 0x1210) + if (!Compress::Raw::Zlib::is_zlibng && ZLIB_VERNUM() < 0x1210) { is $flags, 0, "zlibCompileFlags == 0 if < 1.2.1"; } diff --git a/cpan/Compress-Raw-Zlib/t/07bufsize.t b/cpan/Compress-Raw-Zlib/t/07bufsize.t index 46608eab2c33..d9af9a1654cd 100644 --- a/cpan/Compress-Raw-Zlib/t/07bufsize.t +++ b/cpan/Compress-Raw-Zlib/t/07bufsize.t @@ -11,7 +11,6 @@ use warnings; use bytes; use Test::More ; -use CompTestUtils; BEGIN { @@ -30,6 +29,7 @@ BEGIN use_ok('Compress::Raw::Zlib', 2) ; } +use CompTestUtils; my $hello = < 107 + $extra ; + plan tests => 108 + $extra ; use_ok('Compress::Raw::Zlib', 2) ; } +use CompTestUtils; +test_zlib_header_matches_library(); my $hello = "I am a HAL 9000 computer" x 2001; my $tmp = $hello ; diff --git a/cpan/Compress-Raw-Zlib/t/18lvalue.t b/cpan/Compress-Raw-Zlib/t/18lvalue.t index 98d8423d10c1..a897911eeb5f 100644 --- a/cpan/Compress-Raw-Zlib/t/18lvalue.t +++ b/cpan/Compress-Raw-Zlib/t/18lvalue.t @@ -11,7 +11,6 @@ use warnings; use bytes; use Test::More ; -use CompTestUtils; BEGIN { @@ -28,6 +27,8 @@ BEGIN use_ok('Compress::Raw::Zlib', 2) ; } +use CompTestUtils; + my $hello = <