summaryrefslogtreecommitdiff
path: root/cpan/Compress-Raw-Bzip2
diff options
context:
space:
mode:
authorPaul <paul@paul-desktop.(none)>2012-08-04 16:53:10 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2012-08-08 14:02:57 +0100
commit9d90bd60fec830834e56dfd4cc1aaf499c322831 (patch)
tree95693a4406df5392d9c790f305209c24bbba52f4 /cpan/Compress-Raw-Bzip2
parent2cc12391b30fddb6f67ee8dca6140a805774bc15 (diff)
downloadperl-9d90bd60fec830834e56dfd4cc1aaf499c322831.tar.gz
MAgic for Zlib & Bzip2
Diffstat (limited to 'cpan/Compress-Raw-Bzip2')
-rw-r--r--cpan/Compress-Raw-Bzip2/Bzip2.xs68
-rw-r--r--cpan/Compress-Raw-Bzip2/Changes5
-rw-r--r--cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm2
3 files changed, 46 insertions, 29 deletions
diff --git a/cpan/Compress-Raw-Bzip2/Bzip2.xs b/cpan/Compress-Raw-Bzip2/Bzip2.xs
index 128063c9b7..f2ccc7913e 100644
--- a/cpan/Compress-Raw-Bzip2/Bzip2.xs
+++ b/cpan/Compress-Raw-Bzip2/Bzip2.xs
@@ -323,11 +323,13 @@ char * string ;
if (SvREADONLY(sv) && PL_curcop != &PL_compiling)
croak("%s: buffer parameter is read-only", string);
- SvUPGRADE(sv, SVt_PV) ;
+ SvUPGRADE(sv, SVt_PV);
+
if (wipe)
- sv_setpv(sv, "") ;
+ sv_setpv(sv, "") ;
else
(void)SvPVbyte_force(sv, na) ;
+
return sv ;
}
@@ -493,9 +495,9 @@ bzdeflate (s, buf, output)
#ifdef UTF8_AVAILABLE
if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in " COMPRESS_CLASS "::bzdeflate input parameter");
-#endif
- s->stream.next_in = SvPV_nomg_nolen(buf);
- s->stream.avail_in = SvCUR(buf);
+#endif
+ s->stream.next_in = (char*)SvPVbyte_nolen(buf) ;
+ s->stream.avail_in = SvCUR(buf) ;
/* and retrieve the output buffer */
output = deRef_l(output, "deflate") ;
@@ -503,19 +505,22 @@ bzdeflate (s, buf, output)
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in " COMPRESS_CLASS "::bzdeflate output parameter");
#endif
- if((s->flags & FLAG_APPEND_OUTPUT) != FLAG_APPEND_OUTPUT)
+
+ if((s->flags & FLAG_APPEND_OUTPUT) != FLAG_APPEND_OUTPUT) {
SvCUR_set(output, 0);
+ /* sv_setpvn(output, "", 0); */
+ }
cur_length = SvCUR(output) ;
- s->stream.next_out = SvPVX(output) + cur_length;
+ s->stream.next_out = (char*) SvPVX(output) + cur_length;
increment = SvLEN(output) - cur_length;
s->stream.avail_out = increment;
while (s->stream.avail_in != 0) {
if (s->stream.avail_out == 0) {
/* out of space in the output buffer so make it bigger */
- Sv_Grow(output, SvLEN(output) + bufinc) ;
+ s->stream.next_out = Sv_Grow(output, SvLEN(output) + bufinc) ;
cur_length += increment ;
- s->stream.next_out = SvPVX(output) + cur_length ;
+ s->stream.next_out += cur_length ;
increment = bufinc ;
s->stream.avail_out = increment;
bufinc *= 2 ;
@@ -565,19 +570,21 @@ bzclose(s, output)
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)
+ if(! s->flags & FLAG_APPEND_OUTPUT) {
SvCUR_set(output, 0);
+ /* sv_setpvn(output, "", 0); */
+ }
cur_length = SvCUR(output) ;
- s->stream.next_out = SvPVX(output) + cur_length;
+ s->stream.next_out = (char*) SvPVX(output) + cur_length;
increment = SvLEN(output) - cur_length;
s->stream.avail_out = increment;
for (;;) {
if (s->stream.avail_out == 0) {
/* consumed all the available output, so extend it */
- Sv_Grow(output, SvLEN(output) + bufinc) ;
+ s->stream.next_out = Sv_Grow(output, SvLEN(output) + bufinc) ;
cur_length += increment ;
- s->stream.next_out = SvPVX(output) + cur_length ;
+ s->stream.next_out += cur_length ;
increment = bufinc ;
s->stream.avail_out = increment;
bufinc *= 2 ;
@@ -624,19 +631,21 @@ bzflush(s, output)
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)
+ if(! s->flags & FLAG_APPEND_OUTPUT) {
SvCUR_set(output, 0);
+ /* sv_setpvn(output, "", 0); */
+ }
cur_length = SvCUR(output) ;
- s->stream.next_out = SvPVX(output) + cur_length;
+ s->stream.next_out = (char*) SvPVX(output) + cur_length;
increment = SvLEN(output) - cur_length;
s->stream.avail_out = increment;
for (;;) {
if (s->stream.avail_out == 0) {
/* consumed all the available output, so extend it */
- Sv_Grow(output, SvLEN(output) + bufinc) ;
+ s->stream.next_out = Sv_Grow(output, SvLEN(output) + bufinc) ;
cur_length += increment ;
- s->stream.next_out = SvPVX(output) + cur_length ;
+ s->stream.next_out += cur_length ;
increment = bufinc ;
s->stream.avail_out = increment;
bufinc *= 2 ;
@@ -733,8 +742,8 @@ bzinflate (s, buf, output)
#endif
/* initialise the input buffer */
- s->stream.next_in = SvPV_nomg_nolen(buf);
- s->stream.avail_in = stmp = SvCUR(buf);
+ s->stream.next_in = (char*)SvPVbyte_force(buf, stmp) ;
+ s->stream.avail_in = SvCUR(buf);
/* and retrieve the output buffer */
output = deRef_l(output, "bzinflate") ;
@@ -764,7 +773,7 @@ bzinflate (s, buf, output)
*/
if (SvLEN(output) > cur_length + 1)
{
- s->stream.next_out = SvPVX(output) + cur_length;
+ s->stream.next_out = (char*) SvPVX(output) + cur_length;
increment = SvLEN(output) - cur_length - 1;
s->stream.avail_out = increment;
}
@@ -778,9 +787,9 @@ bzinflate (s, buf, output)
if (s->stream.avail_out == 0) {
/* out of space in the output buffer so make it bigger */
- Sv_Grow(output, SvLEN(output) + bufinc + 1) ;
+ s->stream.next_out = Sv_Grow(output, SvLEN(output) + bufinc + 1) ;
cur_length += increment ;
- s->stream.next_out = SvPVX(output) + cur_length ;
+ s->stream.next_out += cur_length ;
increment = bufinc ;
s->stream.avail_out = increment;
bufinc *= 2 ;
@@ -789,7 +798,10 @@ bzinflate (s, buf, output)
/* DispStream(s, "pre"); */
RETVAL = BZ2_bzDecompress (&(s->stream));
- /* DispStream(s, "apres"); */
+ /*
+ printf("Status %d\n", RETVAL);
+ DispStream(s, "apres");
+ */
if (RETVAL != BZ_OK || s->flags & FLAG_LIMIT_OUTPUT)
break ;
@@ -813,12 +825,12 @@ bzinflate (s, buf, output)
SvPOK_only(output);
SvCUR_set(output, prefix_length + s->bytesInflated) ;
- *SvEND(output) = '\0' ;
+ *SvEND(output) = '\0';
#ifdef UTF8_AVAILABLE
if (out_utf8)
- sv_utf8_upgrade(output) ;
+ sv_utf8_upgrade(output);
#endif
- SvSETMAGIC(output) ;
+ SvSETMAGIC(output);
/* fix the input buffer */
if (s->flags & FLAG_CONSUME_INPUT) {
@@ -826,8 +838,8 @@ bzinflate (s, buf, output)
SvCUR_set(buf, in) ;
if (in)
Move(s->stream.next_in, SvPVX(buf), in, char) ;
- *SvEND(buf) = '\0' ;
- SvSETMAGIC(buf) ;
+ *SvEND(buf) = '\0';
+ SvSETMAGIC(buf);
}
}
OUTPUT:
diff --git a/cpan/Compress-Raw-Bzip2/Changes b/cpan/Compress-Raw-Bzip2/Changes
index 7dd052b51f..0ee8d279ad 100644
--- a/cpan/Compress-Raw-Bzip2/Changes
+++ b/cpan/Compress-Raw-Bzip2/Changes
@@ -1,6 +1,11 @@
CHANGES
-------
+ 2.055 4 August 2012
+
+ * Fix misuse of magic in API
+ [#78080]
+
2.052 29 April 2012
* No Changes
diff --git a/cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm b/cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm
index 589f390745..9263d658a7 100644
--- a/cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm
+++ b/cpan/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm
@@ -12,7 +12,7 @@ use Carp ;
use bytes ;
our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD);
-$VERSION = '2.05201';
+$VERSION = '2.055';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;