# ignore .patch from rsync, and any generated patch files from git-am
-*.patch
+/*.patch
# ignore local .config files
.config
# these are generated by make_patchnum.sh from git or from a .patchfile
cpan/bignum/t/scope_r.t See if no bigrat works
cpan/Compress-Raw-Bzip2/Bzip2.xs
cpan/Compress-Raw-Bzip2/bzip2-src/blocksort.c
+cpan/Compress-Raw-Bzip2/bzip2-src/bzip2.patch
cpan/Compress-Raw-Bzip2/bzip2-src/bzlib.c
cpan/Compress-Raw-Bzip2/bzip2-src/bzlib.h
cpan/Compress-Raw-Bzip2/bzip2-src/bzlib_private.h
},
'Compress::Raw::Bzip2' => {
- 'DISTRIBUTION' => 'PMQS/Compress-Raw-Bzip2-2.093.tar.gz',
+ 'DISTRIBUTION' => 'PMQS/Compress-Raw-Bzip2-2.096.tar.gz',
'FILES' => q[cpan/Compress-Raw-Bzip2],
'EXCLUDED' => [
qr{^t/Test/},
#include "perl.h"
#include "XSUB.h"
-#include "bzlib.h"
+#include "bzlib.h"
#ifdef USE_PPPORT_H
# define NEED_sv_2pv_nolen
-# include "ppport.h"
+# include "ppport.h"
#endif
#if PERL_REVISION == 5 && (PERL_VERSION < 8 || (PERL_VERSION == 8 && PERL_SUBVERSION < 4 ))
#define FLAG_CONSUME_INPUT 8
#define FLAG_LIMIT_OUTPUT 16
bz_stream stream;
- uInt bufsize;
+ uInt bufsize;
int last_error ;
uLong bytesInflated ;
uLong compressedBytes ;
uLong uncompressedBytes ;
-
+
} di_stream;
typedef di_stream * deflateStream ;
sv_setpv(var, ((err) ? GetErrorString(err) : "")) ; \
SvNOK_on(var);
-
+
#if defined(__SYMBIAN32__)
# define NO_WRITEABLE_DATA
#endif
int error_no ;
#endif
{
- return(char*) my_z_errmsg[4 - error_no];
+ return(char*) my_z_errmsg[4 - error_no];
}
static void
ZMALLOC(s, di_stream) ;
return s ;
-
+
}
static void
}
-static SV*
+static SV*
#ifdef CAN_PROTOTYPE
deRef(SV * sv, const char * string)
#else
dTHX;
bool wipe = 0 ;
STRLEN na;
-
+
SvGETMAGIC(sv);
wipe = ! SvOK(sv) ;
/* Check this version of bzip2 is == 1 */
if (BZ2_bzlibVersion()[0] != '1')
croak(COMPRESS_CLASS " needs bzip2 version 1.x, you have %s\n", BZ2_bzlibVersion()) ;
-
+
MODULE = Compress::Raw::Bzip2 PACKAGE = Compress::Raw::Bzip2
#endif
if ((s = InitStream() )) {
- err = BZ2_bzCompressInit ( &(s->stream),
- blockSize100k,
+ err = BZ2_bzCompressInit ( &(s->stream),
+ blockSize100k,
verbosity,
workfactor );
XPUSHs(sv) ;
}
}
-
+
MODULE = Compress::Raw::Bzip2 PACKAGE = Compress::Raw::Bzip2
Compress::Raw::Bzip2 s
const char * message
-DualType
+DualType
bzdeflate (s, buf, output)
Compress::Raw::Bzip2 s
SV * buf
- SV * output
+ SV * output
uInt cur_length = NO_INIT
uInt increment = NO_INIT
int RETVAL = 0;
/* If the input buffer is a reference, dereference it */
buf = deRef(buf, "deflate") ;
-
+
/* initialise the input buffer */
-#ifdef UTF8_AVAILABLE
+#ifdef UTF8_AVAILABLE
if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in " COMPRESS_CLASS "::bzdeflate input parameter");
-#endif
+#endif
s->stream.next_in = (char*)SvPV_nomg(buf, origlen) ;
s->stream.avail_in = (unsigned int) origlen;
-
+
/* and retrieve the output buffer */
output = deRef_l(output, "deflate") ;
-#ifdef UTF8_AVAILABLE
+#ifdef UTF8_AVAILABLE
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in " COMPRESS_CLASS "::bzdeflate output parameter");
-#endif
+#endif
- if((s->flags & FLAG_APPEND_OUTPUT) != FLAG_APPEND_OUTPUT) {
- SvCUR_set(output, 0);
- /* sv_setpvn(output, "", 0); */
- }
+ if((s->flags & FLAG_APPEND_OUTPUT) == FLAG_APPEND_OUTPUT) {
+ SvOOK_off(output);
+ } else {
+ SvCUR_set(output, 0);
+ }
cur_length = SvCUR(output) ;
s->stream.next_out = (char*) SvPVX(output) + cur_length;
increment = SvLEN(output) - cur_length;
}
RETVAL = BZ2_bzCompress(&(s->stream), BZ_RUN);
- if (RETVAL != BZ_RUN_OK)
+ if (RETVAL != BZ_RUN_OK)
break;
}
}
OUTPUT:
RETVAL
-
+
void
DESTROY(s)
DualType
bzclose(s, output)
Compress::Raw::Bzip2 s
- SV * output
+ SV * output
uInt cur_length = NO_INIT
uInt increment = NO_INIT
uInt bufinc = NO_INIT
CODE:
bufinc = s->bufsize;
-
+
s->stream.avail_in = 0; /* should be zero already anyway */
-
+
/* retrieve the output buffer */
output = deRef_l(output, "close") ;
-#ifdef UTF8_AVAILABLE
+#ifdef UTF8_AVAILABLE
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in " COMPRESS_CLASS "::bzclose input parameter");
-#endif
- if((s->flags & FLAG_APPEND_OUTPUT) != FLAG_APPEND_OUTPUT) {
- SvCUR_set(output, 0);
- /* sv_setpvn(output, "", 0); */
- }
+#endif
+ if((s->flags & FLAG_APPEND_OUTPUT) == FLAG_APPEND_OUTPUT) {
+ SvOOK_off(output);
+ } else {
+ SvCUR_set(output, 0);
+ }
cur_length = SvCUR(output) ;
s->stream.next_out = (char*) SvPVX(output) + cur_length;
increment = SvLEN(output) - cur_length;
bufinc *= 2 ;
}
RETVAL = BZ2_bzCompress(&(s->stream), BZ_FINISH);
-
+
/* deflate has finished flushing only when it hasn't used up
- * all the available space in the output buffer:
+ * all the available space in the output buffer:
*/
/* if (s->stream.avail_out != 0 || RETVAL < 0 ) */
if (RETVAL == BZ_STREAM_END || RETVAL < 0 )
break;
}
-
+
/* RETVAL = (RETVAL == BZ_STREAM_END ? BZ_OK : RETVAL) ; */
s->last_error = RETVAL ;
s->compressedBytes += cur_length + increment - s->stream.avail_out ;
-
+
if (RETVAL == BZ_STREAM_END) {
SvPOK_only(output);
SvCUR_set(output, cur_length + increment - s->stream.avail_out) ;
DualType
bzflush(s, output)
Compress::Raw::Bzip2 s
- SV * output
+ SV * output
uInt cur_length = NO_INIT
uInt increment = NO_INIT
uInt bufinc = NO_INIT
CODE:
bufinc = s->bufsize;
-
+
s->stream.avail_in = 0; /* should be zero already anyway */
-
+
/* retrieve the output buffer */
output = deRef_l(output, "close") ;
-#ifdef UTF8_AVAILABLE
+#ifdef UTF8_AVAILABLE
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in " COMPRESS_CLASS "::bzflush input parameter");
-#endif
- if((s->flags & FLAG_APPEND_OUTPUT) != FLAG_APPEND_OUTPUT) {
- SvCUR_set(output, 0);
- /* sv_setpvn(output, "", 0); */
- }
+#endif
+ if((s->flags & FLAG_APPEND_OUTPUT) == FLAG_APPEND_OUTPUT) {
+ SvOOK_off(output);
+ } else {
+ SvCUR_set(output, 0);
+ }
cur_length = SvCUR(output) ;
s->stream.next_out = (char*) SvPVX(output) + cur_length;
increment = SvLEN(output) - cur_length;
bufinc *= 2 ;
}
RETVAL = BZ2_bzCompress(&(s->stream), BZ_FLUSH);
-
+
if (RETVAL == BZ_RUN_OK || RETVAL < 0)
break;
/* deflate has finished flushing only when it hasn't used up
- * all the available space in the output buffer:
+ * all the available space in the output buffer:
*/
/* RETVAL == if (s->stream.avail_out != 0 || RETVAL < 0 )
break; */
}
-
+
/* RETVAL = (RETVAL == BZ_STREAM_END ? BZ_OK : RETVAL) ; */
s->last_error = RETVAL ;
s->compressedBytes += cur_length + increment - s->stream.avail_out ;
-
+
if (RETVAL == BZ_RUN_OK) {
SvPOK_only(output);
SvCUR_set(output, cur_length + increment - s->stream.avail_out) ;
OUTPUT:
RETVAL
-
+
MODULE = Compress::Raw::Bunzip2 PACKAGE = Compress::Raw::Bunzip2
void
Compress::Raw::Bunzip2 s
const char * message
-DualType
+DualType
bzinflate (s, buf, output)
Compress::Raw::Bunzip2 s
SV * buf
- SV * output
+ SV * output
uInt cur_length = 0;
uInt prefix_length = 0;
uInt increment = 0;
STRLEN na = NO_INIT ;
STRLEN origlen = NO_INIT
PREINIT:
-#ifdef UTF8_AVAILABLE
+#ifdef UTF8_AVAILABLE
bool out_utf8 = FALSE;
-#endif
+#endif
CODE:
bufinc = s->bufsize;
/* If the buffer is a reference, dereference it */
croak(UNCOMPRESS_CLASS "::bzinflate input parameter cannot be read-only when ConsumeInput is specified");
SvPV_force(buf, na);
}
-#ifdef UTF8_AVAILABLE
+#ifdef UTF8_AVAILABLE
if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in " UNCOMPRESS_CLASS "::bzinflate input parameter");
-#endif
-
+#endif
+
/* initialise the input buffer */
s->stream.next_in = (char*)SvPV_nomg(buf, origlen) ;
s->stream.avail_in = (unsigned int) origlen;
-
+
/* and retrieve the output buffer */
output = deRef_l(output, "bzinflate") ;
-#ifdef UTF8_AVAILABLE
+#ifdef UTF8_AVAILABLE
if (DO_UTF8(output))
out_utf8 = TRUE ;
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in " UNCOMPRESS_CLASS "::bzinflate output parameter");
-#endif
- if((s->flags & FLAG_APPEND_OUTPUT) != FLAG_APPEND_OUTPUT) {
- SvCUR_set(output, 0);
- }
+#endif
+ if((s->flags & FLAG_APPEND_OUTPUT) == FLAG_APPEND_OUTPUT) {
+ SvOOK_off(output);
+ } else {
+ SvCUR_set(output, 0);
+ }
/* Assume no output buffer - the code below will update if there is any available */
s->stream.avail_out = 0;
if (SvLEN(output)) {
prefix_length = cur_length = SvCUR(output) ;
-
+
if (s->flags & FLAG_LIMIT_OUTPUT && SvLEN(output) - cur_length - 1 < bufinc)
{
Sv_Grow(output, bufinc + cur_length + 1) ;
}
-
- /* Only setup the stream output pointers if there is spare
+
+ /* Only setup the stream output pointers if there is spare
capacity in the outout SV
*/
if (SvLEN(output) > cur_length + 1)
}
s->bytesInflated = 0;
-
+
RETVAL = BZ_OK;
-
+
while (1) {
if (s->stream.avail_out == 0) {
/* DispStream(s, "pre"); */
RETVAL = BZ2_bzDecompress (&(s->stream));
- /*
+ /*
printf("Status %d\n", RETVAL);
- DispStream(s, "apres");
- */
- if (RETVAL != BZ_OK || s->flags & FLAG_LIMIT_OUTPUT)
+ DispStream(s, "apres");
+ */
+ if (RETVAL != BZ_OK || s->flags & FLAG_LIMIT_OUTPUT)
break ;
if (s->stream.avail_out == 0)
RETVAL = BZ_OK ;
break ;
}
-
+
}
-
+
s->last_error = RETVAL ;
if (RETVAL == BZ_OK || RETVAL == BZ_STREAM_END) {
unsigned in ;
SvPOK_only(output);
SvCUR_set(output, prefix_length + s->bytesInflated) ;
*SvEND(output) = '\0';
-#ifdef UTF8_AVAILABLE
+#ifdef UTF8_AVAILABLE
if (out_utf8)
sv_utf8_upgrade(output);
-#endif
+#endif
SvSETMAGIC(output);
/* fix the input buffer */
in = s->stream.avail_in ;
SvCUR_set(buf, in) ;
if (in)
- Move(s->stream.next_in, SvPVX(buf), in, char) ;
+ Move(s->stream.next_in, SvPVX(buf), in, char) ;
*SvEND(buf) = '\0';
SvSETMAGIC(buf);
}
--- /dev/null
+diff --git a/bzip2.c b/bzip2.c
+index d95d280..7852cc4 100644
+--- a/bzip2.c
++++ b/bzip2.c
+@@ -1070,7 +1070,11 @@ void applySavedFileAttrToOutputFile ( IntNative fd )
+ retVal = fchmod ( fd, fileMetaInfo.st_mode );
+ ERROR_IF_NOT_ZERO ( retVal );
+
+- (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
++#if __GNUC__
++ int unused __attribute__((unused));
++ unused =
++#endif
++ fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
+ /* chown() will in many cases return with EPERM, which can
+ be safely ignored.
+ */
+diff --git a/bzip2recover.c b/bzip2recover.c
+index a8131e0..0925048 100644
+--- a/bzip2recover.c
++++ b/bzip2recover.c
+@@ -153,7 +153,7 @@ typedef
+ /*---------------------------------------------*/
+ static BitStream* bsOpenReadStream ( FILE* stream )
+ {
+- BitStream *bs = malloc ( sizeof(BitStream) );
++ BitStream *bs = (BitStream *) malloc ( sizeof(BitStream) );
+ if (bs == NULL) mallocFail ( sizeof(BitStream) );
+ bs->handle = stream;
+ bs->buffer = 0;
+@@ -166,7 +166,7 @@ static BitStream* bsOpenReadStream ( FILE* stream )
+ /*---------------------------------------------*/
+ static BitStream* bsOpenWriteStream ( FILE* stream )
+ {
+- BitStream *bs = malloc ( sizeof(BitStream) );
++ BitStream *bs = (BitStream *) malloc ( sizeof(BitStream) );
+ if (bs == NULL) mallocFail ( sizeof(BitStream) );
+ bs->handle = stream;
+ bs->buffer = 0;
+diff --git a/bzlib.c b/bzlib.c
+index 2178655..aaf1b40 100644
+--- a/bzlib.c
++++ b/bzlib.c
+@@ -165,7 +165,7 @@ int BZ_API(BZ2_bzCompressInit)
+ if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
+ if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
+
+- s = BZALLOC( sizeof(EState) );
++ s = (EState*) BZALLOC( sizeof(EState) );
+ if (s == NULL) return BZ_MEM_ERROR;
+ s->strm = strm;
+
+@@ -174,9 +174,9 @@ int BZ_API(BZ2_bzCompressInit)
+ s->ftab = NULL;
+
+ n = 100000 * blockSize100k;
+- s->arr1 = BZALLOC( n * sizeof(UInt32) );
+- s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
+- s->ftab = BZALLOC( 65537 * sizeof(UInt32) );
++ s->arr1 = (UInt32*) BZALLOC( n * sizeof(UInt32) );
++ s->arr2 = (UInt32*) BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
++ s->ftab = (UInt32*) BZALLOC( 65537 * sizeof(UInt32) );
+
+ if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
+ if (s->arr1 != NULL) BZFREE(s->arr1);
+@@ -362,7 +362,7 @@ Bool handle_compress ( bz_stream* strm )
+ {
+ Bool progress_in = False;
+ Bool progress_out = False;
+- EState* s = strm->state;
++ EState* s = (EState*) strm->state;
+
+ while (True) {
+
+@@ -409,7 +409,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
+ Bool progress;
+ EState* s;
+ if (strm == NULL) return BZ_PARAM_ERROR;
+- s = strm->state;
++ s = (EState*) strm->state;
+ if (s == NULL) return BZ_PARAM_ERROR;
+ if (s->strm != strm) return BZ_PARAM_ERROR;
+
+@@ -469,7 +469,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
+ {
+ EState* s;
+ if (strm == NULL) return BZ_PARAM_ERROR;
+- s = strm->state;
++ s = (EState*) strm->state;
+ if (s == NULL) return BZ_PARAM_ERROR;
+ if (s->strm != strm) return BZ_PARAM_ERROR;
+
+@@ -505,7 +505,7 @@ int BZ_API(BZ2_bzDecompressInit)
+ if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
+ if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
+
+- s = BZALLOC( sizeof(DState) );
++ s = (DState*) BZALLOC( sizeof(DState) );
+ if (s == NULL) return BZ_MEM_ERROR;
+ s->strm = strm;
+ strm->state = s;
+@@ -684,7 +684,10 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
+
+
+ /*---------------------------------------------------*/
+-__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
++#ifndef __cplusplus
++__inline__
++#endif
++Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
+ {
+ Int32 nb, na, mid;
+ nb = 0;
+@@ -810,7 +813,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
+ Bool corrupt;
+ DState* s;
+ if (strm == NULL) return BZ_PARAM_ERROR;
+- s = strm->state;
++ s = (DState*) strm->state;
+ if (s == NULL) return BZ_PARAM_ERROR;
+ if (s->strm != strm) return BZ_PARAM_ERROR;
+
+@@ -863,7 +866,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
+ {
+ DState* s;
+ if (strm == NULL) return BZ_PARAM_ERROR;
+- s = strm->state;
++ s = (DState*) strm->state;
+ if (s == NULL) return BZ_PARAM_ERROR;
+ if (s->strm != strm) return BZ_PARAM_ERROR;
+
+@@ -934,7 +937,7 @@ BZFILE* BZ_API(BZ2_bzWriteOpen)
+ if (ferror(f))
+ { BZ_SETERR(BZ_IO_ERROR); return NULL; };
+
+- bzf = malloc ( sizeof(bzFile) );
++ bzf = (bzFile*) malloc ( sizeof(bzFile) );
+ if (bzf == NULL)
+ { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
+
+@@ -982,7 +985,7 @@ void BZ_API(BZ2_bzWrite)
+ { BZ_SETERR(BZ_OK); return; };
+
+ bzf->strm.avail_in = len;
+- bzf->strm.next_in = buf;
++ bzf->strm.next_in = (char*)buf;
+
+ while (True) {
+ bzf->strm.avail_out = BZ_MAX_UNUSED;
+@@ -1107,7 +1110,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
+ if (ferror(f))
+ { BZ_SETERR(BZ_IO_ERROR); return NULL; };
+
+- bzf = malloc ( sizeof(bzFile) );
++ bzf = (bzFile*) malloc ( sizeof(bzFile) );
+ if (bzf == NULL)
+ { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
+
+@@ -1179,7 +1182,7 @@ int BZ_API(BZ2_bzRead)
+ { BZ_SETERR(BZ_OK); return 0; };
+
+ bzf->strm.avail_out = len;
+- bzf->strm.next_out = buf;
++ bzf->strm.next_out = (char*) buf;
+
+ while (True) {
+
+diff --git a/bzlib_private.h b/bzlib_private.h
+index 3755a6f..2578c2d 100644
+--- a/bzlib_private.h
++++ b/bzlib_private.h
+@@ -128,7 +128,7 @@ extern void bz_internal_error ( int errcode );
+
+ /*-- Stuff for randomising repetitive blocks. --*/
+
+-extern Int32 BZ2_rNums[512];
++extern const Int32 BZ2_rNums[512];
+
+ #define BZ_RAND_DECLS \
+ Int32 rNToGo; \
+@@ -152,7 +152,7 @@ extern Int32 BZ2_rNums[512];
+
+ /*-- Stuff for doing CRCs. --*/
+
+-extern UInt32 BZ2_crc32Table[256];
++extern const UInt32 BZ2_crc32Table[256];
+
+ #define BZ_INITIALISE_CRC(crcVar) \
+ { \
+diff --git a/crctable.c b/crctable.c
+index 2b33c25..a9212db 100644
+--- a/crctable.c
++++ b/crctable.c
+@@ -28,7 +28,7 @@
+ comp.compression FAQ.
+ --*/
+
+-UInt32 BZ2_crc32Table[256] = {
++const UInt32 BZ2_crc32Table[256] = {
+
+ /*-- Ugly, innit? --*/
+
+diff --git a/decompress.c b/decompress.c
+index a1a0bac..5afd651 100644
+--- a/decompress.c
++++ b/decompress.c
+@@ -209,13 +209,13 @@ Int32 BZ2_decompress ( DState* s )
+ s->blockSize100k -= BZ_HDR_0;
+
+ if (s->smallDecompress) {
+- s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
+- s->ll4 = BZALLOC(
++ s->ll16 = (UInt16*) BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
++ s->ll4 = (UChar*) BZALLOC(
+ ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
+ );
+ if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
+ } else {
+- s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
++ s->tt = (UInt32*) BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
+ if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
+ }
+
+diff --git a/randtable.c b/randtable.c
+index bdc6d4a..70666a1 100644
+--- a/randtable.c
++++ b/randtable.c
+@@ -23,7 +23,7 @@
+
+
+ /*---------------------------------------------*/
+-Int32 BZ2_rNums[512] = {
++const Int32 BZ2_rNums[512] = {
+ 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
+ 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
+ 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
use bytes ;
our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD);
-$VERSION = '2.093';
+$VERSION = '2.096';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
=head1 SUPPORT
-General feedback/questions/bug reports should be sent to
+General feedback/questions/bug reports should be sent to
L<https://github.com/pmqs/Compress-Raw-Bzip2/issues> (preferred) or
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Compress-Raw-Bzip2>.
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2005-2019 Paul Marquess. All rights reserved.
+Copyright (c) 2005-2020 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.
if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
- my $VERSION = '2.093';
+ my $VERSION = '2.096';
my @NAMES = qw(
);
#use CompTestUtils;
-BEGIN
-{
+BEGIN
+{
# use Test::NoWarnings, if available
my $extra = 0 ;
$extra = 1
my $count = 0 ;
if ($] < 5.005) {
- $count = 103 ;
+ $count = 127 ;
}
elsif ($] >= 5.006) {
- $count = 173 ;
+ $count = 197 ;
}
else {
- $count = 131 ;
+ $count = 155 ;
}
plan tests => $count + $extra;
my $hello = "I am a HAL 9000 computer" ;
my @hello = split('', $hello) ;
- my ($err, $x, $X, $status);
-
+ my ($err, $x, $X, $status);
+
ok( ($x, $err) = new Compress::Raw::Bzip2(0), "Create bzdeflate object" );
ok $x, "Compress::Raw::Bzip2 ok" ;
cmp_ok $err, '==', BZ_OK, "status is BZ_OK" ;
-
+
is $x->uncompressedBytes(), 0, "uncompressedBytes() == 0" ;
is $x->compressedBytes(), 0, "compressedBytes() == 0" ;
{
$status = $x->bzdeflate($_, $X) ;
last unless $status == BZ_RUN_OK ;
-
+
$Answer .= $X ;
}
-
+
cmp_ok $status, '==', BZ_RUN_OK, "bzdeflate returned BZ_RUN_OK" ;
-
+
cmp_ok $x->bzflush($X), '==', BZ_RUN_OK, "bzflush returned BZ_RUN_OK" ;
$Answer .= $X ;
-
+
is $x->uncompressedBytes(), length $hello, "uncompressedBytes ok" ;
is $x->compressedBytes(), length $Answer, "compressedBytes ok" ;
-
+
cmp_ok $x->bzclose($X), '==', BZ_STREAM_END, "bzclose returned BZ_STREAM_END";
$Answer .= $X ;
#open F, ">/tmp/xx1"; print F $Answer ; close F;
my @Answer = split('', $Answer) ;
-
+
my $k;
ok(($k, $err) = new Compress::Raw::Bunzip2(0, 0));
ok $k, "Compress::Raw::Bunzip2 ok" ;
cmp_ok $err, '==', BZ_OK, "status is BZ_OK" ;
-
+
is $k->compressedBytes(), 0, "compressedBytes() == 0" ;
is $k->uncompressedBytes(), 0, "uncompressedBytes() == 0" ;
my $GOT = '';
$status = $k->bzinflate($_, $Z) ;
$GOT .= $Z ;
last if $status == BZ_STREAM_END or $status != BZ_OK ;
-
+
}
-
+
cmp_ok $status, '==', BZ_STREAM_END, "Got BZ_STREAM_END" ;
is $GOT, $hello, "uncompressed data matches ok" ;
is $k->compressedBytes(), length $Answer, "compressedBytes ok" ;
# ==============================
my $hello = 6529 ;
-
+
ok my ($x, $err) = new Compress::Raw::Bzip2 (1) ;
ok $x ;
cmp_ok $err, '==', BZ_OK ;
-
+
my $status;
my $Answer = '';
-
+
cmp_ok $x->bzdeflate($hello, $Answer), '==', BZ_RUN_OK ;
-
+
cmp_ok $x->bzclose($Answer), '==', BZ_STREAM_END, "bzclose returned BZ_STREAM_END";
-
+
my @Answer = split('', $Answer) ;
-
+
my $k;
ok(($k, $err) = new Compress::Raw::Bunzip2(1, 0) );
ok $k ;
cmp_ok $err, '==', BZ_OK ;
-
+
#my $GOT = '';
my $GOT ;
foreach (@Answer)
{
$status = $k->bzinflate($_, $GOT) ;
last if $status == BZ_STREAM_END or $status != BZ_OK ;
-
+
}
-
+
cmp_ok $status, '==', BZ_STREAM_END ;
is $GOT, $hello ;
my $hello = "I am a HAL 9000 computer" ;
my @hello = split('', $hello) ;
-
+
ok my ($x, $err) = new Compress::Raw::Bzip2 (1) ;
ok $x ;
cmp_ok $err, '==', BZ_OK ;
-
+
my $status;
my $X;
foreach (@hello)
$status = $x->bzdeflate($_, $X) ;
last unless $status == BZ_RUN_OK ;
}
-
+
cmp_ok $status, '==', BZ_RUN_OK ;
-
+
cmp_ok $x->bzclose($X), '==', BZ_STREAM_END ;
-
-
+
+
my @Answer = split('', $X) ;
-
+
my $k;
ok(($k, $err) = new Compress::Raw::Bunzip2( {-Bufsize => 1, -AppendOutput =>1}));
ok $k ;
cmp_ok $err, '==', BZ_OK ;
-
+
my $Z;
foreach (@Answer)
{
$status = $k->bzinflate($_, $Z) ;
last if $status == BZ_STREAM_END or $status != BZ_OK ;
-
+
}
-
+
cmp_ok $status, '==', BZ_STREAM_END ;
is $Z, $hello ;
}
-
+
{
title "bzdeflate/bzinflate - larger buffer";
my $contents = '' ;
foreach (1 .. 50000)
{ $contents .= chr int rand 255 }
-
-
+
+
ok my ($x, $err) = new Compress::Raw::Bzip2(0) ;
ok $x ;
cmp_ok $err, '==', BZ_OK ;
-
+
my (%X, $Y, %Z, $X, $Z);
#cmp_ok $x->bzdeflate($contents, $X{key}), '==', BZ_RUN_OK ;
cmp_ok $x->bzdeflate($contents, $X), '==', BZ_RUN_OK ;
-
+
#$Y = $X{key} ;
$Y = $X ;
-
-
+
+
#cmp_ok $x->bzflush($X{key}), '==', BZ_RUN_OK ;
#$Y .= $X{key} ;
cmp_ok $x->bzclose($X), '==', BZ_STREAM_END ;
$Y .= $X ;
-
-
-
+
+
+
my $keep = $Y ;
my $k;
ok(($k, $err) = new Compress::Raw::Bunzip2(0, 0) );
ok $k ;
cmp_ok $err, '==', BZ_OK ;
-
+
#cmp_ok $k->bzinflate($Y, $Z{key}), '==', BZ_STREAM_END ;
#ok $contents eq $Z{key} ;
cmp_ok $k->bzinflate($Y, $Z), '==', BZ_STREAM_END ;
ok (($k, $err) = new Compress::Raw::Bunzip2(1, 0)) ;
ok $k ;
cmp_ok $err, '==', BZ_OK ;
-
- my $s ;
+
+ my $s ;
my $out ;
my @bits = split('', $keep) ;
foreach my $bit (@bits) {
$s = $k->bzinflate($bit, $out) ;
}
-
+
cmp_ok $s, '==', BZ_STREAM_END ;
-
+
ok $contents eq $out ;
title "bzinflate - check remaining buffer after BZ_STREAM_END, Consume $consume";
ok my $x = new Compress::Raw::Bzip2(0) ;
-
+
my ($X, $Y, $Z);
cmp_ok $x->bzdeflate($hello, $X), '==', BZ_RUN_OK;
cmp_ok $x->bzclose($Y), '==', BZ_STREAM_END;
$X .= $Y ;
-
+
ok my $k = new Compress::Raw::Bunzip2(0, $consume) ;
-
+
my $first = substr($X, 0, 2) ;
my $remember_first = $first ;
my $last = substr($X, 2) ;
title "ConsumeInput and a read-only buffer trapped" ;
ok my $k = new Compress::Raw::Bunzip2(0, 1) ;
-
- my $Z;
+
+ my $Z;
eval { $k->bzinflate("abc", $Z) ; };
like $@, mkErr("Compress::Raw::Bunzip2::bzinflate input parameter cannot be read-only when ConsumeInput is specified");
foreach (1 .. 5000)
{ $contents .= chr int rand 255 }
ok my $x = new Compress::Raw::Bzip2(1) ;
-
+
my $X ;
my $status = $x->bzdeflate(substr($contents,0), $X);
cmp_ok $status, '==', BZ_RUN_OK ;
-
+
cmp_ok $x->bzclose($X), '==', BZ_STREAM_END ;
-
+
my $append = "Appended" ;
$X .= $append ;
-
+
ok my $k = new Compress::Raw::Bunzip2(1, 1) ;
-
- my $Z;
+
+ my $Z;
my $keep = $X ;
$status = $k->bzinflate(substr($X, 0), $Z) ;
-
+
cmp_ok $status, '==', BZ_STREAM_END ;
#print "status $status X [$X]\n" ;
is $contents, $Z ;
my $hello = "I am a HAL 9000 computer" ;
my @hello = split('', $hello) ;
- my ($err, $x, $X, $status);
-
+ my ($err, $x, $X, $status);
+
ok( ($x, $err) = new Compress::Raw::Bzip2 (0) );
ok $x ;
cmp_ok $err, '==', BZ_OK ;
-
+
$X = "" ;
my $Answer = '';
foreach (@hello)
{
$status = $x->bzdeflate($_, $X) ;
last unless $status == BZ_RUN_OK ;
-
+
$Answer .= $X ;
}
-
+
cmp_ok $status, '==', BZ_RUN_OK ;
-
+
cmp_ok $x->bzclose($X), '==', BZ_STREAM_END ;
$Answer .= $X ;
-
+
my @Answer = split('', $Answer) ;
-
+
my $k;
ok(($k, $err) = new Compress::Raw::Bunzip2(1, 0) );
ok $k ;
cmp_ok $err, '==', BZ_OK ;
-
+
my $GOT ;
my $Z;
$Z = 1 ;#x 2000 ;
$status = $k->bzinflate($_, $GOT) ;
last if $status == BZ_STREAM_END or $status != BZ_OK ;
}
-
+
cmp_ok $status, '==', BZ_STREAM_END ;
is $GOT, $hello ;
cmp_ok $x->bzdeflate($data, $X), '==', BZ_RUN_OK ;
cmp_ok $x->bzclose($X), '==', BZ_STREAM_END ;
-
+
my $append = "Appended" ;
$X .= $append ;
my $keep = $X ;
-
+
ok my $k = new Compress::Raw::Bunzip2 ( 1, 1);
-
+
# cmp_ok $k->bzinflate(substr($X, 0, -1), $Z), '==', BZ_STREAM_END ; ;
cmp_ok $k->bzinflate(substr($X, 0), $Z), '==', BZ_STREAM_END ; ;
-
+
ok $hello eq $Z ;
is $X, $append;
-
+
$X = $keep ;
$Z = '';
ok $k = new Compress::Raw::Bunzip2 ( 1, 0);
-
+
cmp_ok $k->bzinflate(substr($X, 0, -1), $Z), '==', BZ_STREAM_END ; ;
#cmp_ok $k->bzinflate(substr($X, 0), $Z), '==', BZ_STREAM_END ; ;
-
+
ok $hello eq $Z ;
is $X, $keep;
-
+
+}
+
+
+{
+ title 'RT#132734: test inflate append OOK output parameter';
+ # https://github.com/pmqs/Compress-Raw-Bzip2/issues/2
+
+ my $hello = "I am a HAL 9000 computer" ;
+ my $data = $hello ;
+
+ my($X, $Z);
+
+ ok my $x = new Compress::Raw::Bzip2 ( {-AppendOutput => 1} );
+
+ cmp_ok $x->bzdeflate($data, $X), '==', BZ_RUN_OK ;
+
+ cmp_ok $x->bzclose($X), '==', BZ_STREAM_END ;
+
+ ok my $k = new Compress::Raw::Bunzip2 ( {-AppendOutput => 1,
+ -ConsumeInput => 1} ) ;
+ $Z = 'prev. ' ;
+ substr($Z, 0, 4, ''); # chop off first 4 characters using offset
+ cmp_ok $Z, 'eq', '. ' ;
+
+ # use Devel::Peek ; Dump($Z) ; # shows OOK flag
+
+ # if (1) { # workaround
+ # my $prev = $Z;
+ # undef $Z ;
+ # $Z = $prev ;
+ # }
+
+ cmp_ok $k->bzinflate($X, $Z), '==', BZ_STREAM_END ;
+ # use Devel::Peek ; Dump($Z) ; # No OOK flag
+
+ cmp_ok $Z, 'eq', ". $hello" ;
+}
+
+
+{
+ title 'RT#132734: test deflate append OOK output parameter';
+ # https://github.com/pmqs/Compress-Raw-Bzip2/issues/2
+
+ my $hello = "I am a HAL 9000 computer" ;
+ my $data = $hello ;
+
+ my($X, $Z);
+
+ $X = 'prev. ' ;
+ substr($X, 0, 6, ''); # chop off all characters using offset
+ cmp_ok $X, 'eq', '' ;
+
+ # use Devel::Peek ; Dump($X) ; # shows OOK flag
+
+ # if (1) { # workaround
+ # my $prev = $Z;
+ # undef $Z ;
+ # $Z = $prev ;
+ # }
+
+ ok my $x = new Compress::Raw::Bzip2 ( { -AppendOutput => 1 } );
+
+ cmp_ok $x->bzdeflate($data, $X), '==', BZ_RUN_OK ;
+
+ cmp_ok $x->bzclose($X), '==', BZ_STREAM_END ;
+
+ ok my $k = new Compress::Raw::Bunzip2 ( {-AppendOutput => 1,
+ -ConsumeInput => 1} ) ;
+ cmp_ok $k->bzinflate($X, $Z), '==', BZ_STREAM_END ;
+
+ is $Z, $hello ;
+}
+
+
+{
+ title 'RT#132734: test flush append OOK output parameter';
+ # https://github.com/pmqs/Compress-Raw-Bzip2/issues/2
+
+ my $hello = "I am a HAL 9000 computer" ;
+ my $data = $hello ;
+
+ my($X, $Z);
+
+ my $F = 'prev. ' ;
+ substr($F, 0, 6, ''); # chop off all characters using offset
+ cmp_ok $F, 'eq', '' ;
+
+ # use Devel::Peek ; Dump($F) ; # shows OOK flag
+
+ ok my $x = new Compress::Raw::Bzip2 ( {-AppendOutput => 1 });
+
+ cmp_ok $x->bzdeflate($data, $X), '==', BZ_RUN_OK ;
+
+ cmp_ok $x->bzclose($F), '==', BZ_STREAM_END ;
+
+ ok my $k = new Compress::Raw::Bunzip2 ( {-AppendOutput => 1,
+ -ConsumeInput => 1} ) ;
+ cmp_ok $k->bzinflate($X . $F, $Z), '==', BZ_STREAM_END ;
+
+ is $Z, $hello ;
}
exit if $] < 5.006 ;
my $hello = "I am a HAL 9000 computer" ;
my @hello = split('', $hello) ;
- my ($err, $x, $X, $status);
-
+ my ($err, $x, $X, $status);
+
ok( ($x, $err) = new Compress::Raw::Bzip2 (1) );
ok $x ;
cmp_ok $err, '==', BZ_OK ;
-
+
$X = "" ;
my $Answer = '';
foreach (@hello)
{
$status = $x->bzdeflate($_, substr($Answer, length($Answer))) ;
last unless $status == BZ_RUN_OK ;
-
+
}
-
+
cmp_ok $status, '==', BZ_RUN_OK ;
-
+
cmp_ok $x->bzclose(substr($Answer, length($Answer))), '==', BZ_STREAM_END ;
-
+
my @Answer = split('', $Answer) ;
-
+
my $k;
ok(($k, $err) = new Compress::Raw::Bunzip2(1, 0) );
ok $k ;
cmp_ok $err, '==', BZ_OK ;
-
+
my $GOT = '';
my $Z;
$Z = 1 ;#x 2000 ;
$status = $k->bzinflate($_, substr($GOT, length($GOT))) ;
last if $status == BZ_STREAM_END or $status != BZ_OK ;
}
-
+
cmp_ok $status, '==', BZ_STREAM_END ;
is $GOT, $hello ;
my $hello = "I am a HAL 9000 computer" ;
my @hello = split('', $hello) ;
- my ($err, $x, $X, $status);
-
+ my ($err, $x, $X, $status);
+
ok( ($x, $err) = new Compress::Raw::Bzip2 (1) );
ok $x ;
cmp_ok $err, '==', BZ_OK ;
-
+
$X = "" ;
my $Answer = '';
foreach (@hello)
{
$status = $x->bzdeflate($_, substr($Answer, 0)) ;
last unless $status == BZ_RUN_OK ;
-
+
}
-
+
cmp_ok $status, '==', BZ_RUN_OK ;
-
+
cmp_ok $x->bzclose(substr($Answer, 0)), '==', BZ_STREAM_END ;
-
+
my @Answer = split('', $Answer) ;
-
+
my $k;
ok(($k, $err) = new Compress::Raw::Bunzip2(1, 0) );
ok $k ;
cmp_ok $err, '==', BZ_OK ;
-
+
my $GOT = '';
my $Z;
$Z = 1 ;#x 2000 ;
$status = $k->bzinflate($_, substr($GOT, 0)) ;
last if $status == BZ_STREAM_END or $status != BZ_OK ;
}
-
+
cmp_ok $status, '==', BZ_STREAM_END ;
is $GOT, $hello ;
}
-