if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in Compress::Zlib::Deflate::deflate input parameter");
#endif
- s->stream.next_in = (Bytef*)SvPVbyte_nolen(buf) ;
- s->stream.avail_in = SvCUR(buf) ;
+ s->stream.next_in = (Bytef*)SvPVbyte(buf, *(STRLEN*)&s->stream.avail_in) ;
+ /* s->stream.avail_in = SvCUR(buf) ; */
if (s->flags & FLAG_CRC32)
s->crc32 = crc32(s->crc32, s->stream.next_in, s->stream.avail_in) ;
uInt cur_length = NO_INIT
uInt prefix_length = NO_INIT
uInt increment = NO_INIT
- STRLEN stmp = NO_INIT
PREINIT:
#ifdef UTF8_AVAILABLE
bool out_utf8 = FALSE;
#endif
/* initialise the input buffer */
- s->stream.next_in = (Bytef*)SvPVbyte_force(buf, stmp) ;
- s->stream.avail_in = SvCUR(buf) ;
+ s->stream.next_in = (Bytef*)SvPVbyte_force(buf, *(STRLEN*)&s->stream.avail_in) ;
/* and retrieve the output buffer */
output = deRef_l(output, "inflate") ;
SV * buf
SV * out
int start_len = NO_INIT
- STRLEN stmp = NO_INIT
ALIAS:
inflate = 1
CODE:
#endif
/* initialise the input buffer */
- s->stream.next_in = (Bytef*)SvPVbyte_force(buf, stmp) ;
- s->stream.avail_in = SvCUR(buf) ;
+ s->stream.next_in = (Bytef*)SvPVbyte_force(buf, *(STRLEN*)&s->stream.avail_in) ;
start_len = s->stream.avail_in ;
s->bytesInflated = 0 ;
do
use_ok('Compress::Zlib', 2) ;
use_ok('Compress::Gzip::Constants') ;
-
- use_ok('IO::Compress::Gzip', qw($GzipError)) ;
}
for my $i (0 .. @text -2)
{
ok $fil->gzreadline($line) > 0;
- ok $line eq $text[$i] ;
+ is $line, $text[$i] ;
ok ! $fil->gzeof() ;
}
# now read the last line
ok $fil->gzreadline($line) > 0;
-ok $line eq $text[-1] ;
+is $line, $text[-1] ;
ok $fil->gzeof() ;
# read past the eof
$got[$i] = $line ;
++ $i ;
}
-ok $i == 2 ;
-ok $got[0] eq $line1 ;
-ok $got[1] eq $line2 ;
+is $i, 2 ;
+is $got[0], $line1 ;
+is $got[1], $line2 ;
ok $fil->gzeof() ;
ok ! $fil->gzclose ;
$got[$i] = $line ;
++ $i ;
}
-ok $i == 2 ;
-ok $got[0] eq $line1 ;
-ok $got[1] eq $line2 ;
+is $i, 2 ;
+is $got[0], $line1 ;
+is $got[1], $line2 ;
ok $fil->gzeof() ;
ok ! $fil->gzclose ;
# case 1: read a line, then a block. The block is
# smaller than the internal block used by
# gzreadline
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
$line1 = "hello hello, I'm back again\n" ;
$line2 = "abc" x 200 ;
my $line3 = "def" x 200 ;
$text = $line1 . $line2 . $line3 ;
+ my $fil;
ok $fil = gzopen($name, "wb"), ' gzopen for write ok' ;
is $fil->gzwrite($text), length $text, ' gzwrite ok' ;
is $fil->gztell(), length $text, ' gztell ok' ;
{
title "Pass gzopen a filehandle - use IO::File" ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = "hello" ;
my $len = length $hello ;
my $f = new IO::File ">$name" ;
ok $f;
- ok my $fil = gzopen($f, "wb") ;
+ my $fil;
+ ok $fil = gzopen($f, "wb") ;
ok $fil->gzwrite($hello) == $len ;
unlink $name ;
- ok $hello eq $uncomp ;
+ is $uncomp, $hello, "got expected output" ;
}
{
title "Pass gzopen a filehandle - use open" ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = "hello" ;
my $len = length $hello ;
open F, ">$name" ;
- ok my $fil = gzopen(*F, "wb") ;
+ my $fil;
+ ok $fil = gzopen(*F, "wb") ;
is $fil->gzwrite($hello), $len ;
unlink $name ;
- ok $hello eq $uncomp ;
+ is $uncomp, $hello ;
}
title "Pass gzopen a filehandle - use $stdin" ;
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $hello = "hello" ;
my $len = length $hello ;
unlink $name ;
- ok $hello eq $uncomp ;
+ is $uncomp, $hello ;
}
{
title 'test parameters for gzopen';
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $fil;
{
title 'Read operations when opened for writing';
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
+ my $fil;
ok $fil = gzopen($name, "wb"), ' gzopen for writing' ;
ok !$fil->gzeof(), ' !eof'; ;
is $fil->gzread(), Z_STREAM_ERROR, " gzread returns Z_STREAM_ERROR" ;
+ ok ! $fil->gzclose, " gzclose ok" ;
}
{
title 'write operations when opened for reading';
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $test = "hello" ;
+ my $fil;
ok $fil = gzopen($name, "wb"), " gzopen for writing" ;
is $fil->gzwrite($text), length $text, " gzwrite ok" ;
ok ! $fil->gzclose, " gzclose ok" ;
title "gzseek" ;
my $buff ;
- my $name ;#= "test.gz" ;
+ my $name ;
my $lex = new LexFile $name ;
my $first = "beginning" ;
{
# seek error cases
- my $name = "test.gz" ;
- my $lex = new LexFile $name ;
+ my $lex = new LexFile my $name ;
my $a = gzopen($name, "w");