This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update IO-Zlib to CPAN version 1.11
authorNicolas R <nicolas@atoomic.org>
Mon, 14 Sep 2020 17:23:11 +0000 (11:23 -0600)
committerTodd Rinaldo <toddr@cpan.org>
Mon, 14 Sep 2020 18:56:45 +0000 (13:56 -0500)
Enable strict and warnings.

Porting/Maintainers.pl
cpan/IO-Zlib/Zlib.pm
cpan/IO-Zlib/t/basic.t
cpan/IO-Zlib/t/external.t
cpan/IO-Zlib/t/getc.t
cpan/IO-Zlib/t/getline.t
cpan/IO-Zlib/t/import.t
cpan/IO-Zlib/t/large.t
cpan/IO-Zlib/t/tied.t
cpan/IO-Zlib/t/uncomp1.t
cpan/IO-Zlib/t/uncomp2.t

index c75405d..da896b5 100755 (executable)
@@ -664,7 +664,7 @@ use File::Glob qw(:case);
     },
 
     'IO::Zlib' => {
-        'DISTRIBUTION' => 'TOMHUGHES/IO-Zlib-1.10.tar.gz',
+        'DISTRIBUTION' => 'TOMHUGHES/IO-Zlib-1.11.tar.gz',
         'FILES'        => q[cpan/IO-Zlib],
     },
 
index 55534b4..84aa5e4 100644 (file)
@@ -6,8 +6,6 @@
 
 package IO::Zlib;
 
-$VERSION = "1.10";
-
 =head1 NAME
 
 IO::Zlib - IO:: style interface to L<Compress::Zlib>
@@ -286,129 +284,170 @@ it and/or modify it under the same terms as Perl itself.
 require 5.006;
 
 use strict;
-use vars qw($VERSION $AUTOLOAD @ISA);
+use warnings;
 
 use Carp;
 use Fcntl qw(SEEK_SET);
+use Symbol;
+use Tie::Handle;
+
+our $VERSION = "1.11";
+our $AUTOLOAD;
+our @ISA = qw(Tie::Handle);
 
 my $has_Compress_Zlib;
+my $gzip_external;
+my $gzip_used;
+my $gzip_read_open = "gzip -dc %s |";
+my $gzip_write_open = "| gzip > %s";
 my $aliased;
 
-sub has_Compress_Zlib {
-    $has_Compress_Zlib;
-}
-
 BEGIN {
     eval { require Compress::Zlib };
     $has_Compress_Zlib = $@ || $Compress::Zlib::VERSION < 2.000 ? 0 : 1;
 }
 
-use Symbol;
-use Tie::Handle;
-
-# These might use some $^O logic.
-my $gzip_read_open   = "gzip -dc %s |";
-my $gzip_write_open  = "| gzip > %s";
-
-my $gzip_external;
-my $gzip_used;
+sub has_Compress_Zlib
+{
+    $has_Compress_Zlib;
+}
 
-sub gzip_read_open {
-    $gzip_read_open;
+sub gzip_external
+{
+    $gzip_external;
 }
 
-sub gzip_write_open {
-    $gzip_write_open;
+sub gzip_used
+{
+    $gzip_used;
 }
 
-sub gzip_external {
-    $gzip_external;
+sub gzip_read_open
+{
+    $gzip_read_open;
 }
 
-sub gzip_used {
-    $gzip_used;
+sub gzip_write_open
+{
+    $gzip_write_open;
 }
 
-sub can_gunzip {
+sub can_gunzip
+{
     $has_Compress_Zlib || $gzip_external;
 }
 
-sub _import {
+sub _import
+{
     my $import = shift;
-    while (@_) {
-       if ($_[0] eq ':gzip_external') {
-           shift;
-           if (@_) {
-               $gzip_external = shift;
-           } else {
-               croak "$import: ':gzip_external' requires an argument";
-           }
-       }
-       elsif ($_[0] eq ':gzip_read_open') {
-           shift;
-           if (@_) {
-               $gzip_read_open = shift;
-               croak "$import: ':gzip_read_open' '$gzip_read_open' is illegal"
-                   unless $gzip_read_open =~ /^.+%s.+\|\s*$/;
-           } else {
-               croak "$import: ':gzip_read_open' requires an argument";
-           }
-       }
-       elsif ($_[0] eq ':gzip_write_open') {
-           shift;
-           if (@_) {
-               $gzip_write_open = shift;
-               croak "$import: ':gzip_write_open' '$gzip_read_open' is illegal"
-                   unless $gzip_write_open =~ /^\s*\|.+%s.*$/;
-           } else {
-               croak "$import: ':gzip_write_open' requires an argument";
-           }
-       }
-       else {
-           last;
-       }
+
+    while (@_)
+    {
+        if ($_[0] eq ':gzip_external')
+        {
+            shift;
+
+            if (@_)
+            {
+                $gzip_external = shift;
+            }
+            else
+            {
+                croak "$import: ':gzip_external' requires an argument";
+            }
+        }
+        elsif ($_[0] eq ':gzip_read_open')
+        {
+            shift;
+
+            if (@_)
+            {
+                $gzip_read_open = shift;
+
+                croak "$import: ':gzip_read_open' '$gzip_read_open' is illegal"
+                    unless $gzip_read_open =~ /^.+%s.+\|\s*$/;
+            }
+            else
+            {
+                croak "$import: ':gzip_read_open' requires an argument";
+            }
+        }
+        elsif ($_[0] eq ':gzip_write_open')
+        {
+            shift;
+
+            if (@_)
+            {
+                $gzip_write_open = shift;
+
+                croak "$import: ':gzip_write_open' '$gzip_read_open' is illegal"
+                    unless $gzip_write_open =~ /^\s*\|.+%s.*$/;
+            }
+            else
+            {
+                croak "$import: ':gzip_write_open' requires an argument";
+            }
+        }
+        else
+        {
+            last;
+        }
     }
+
     return @_;
 }
 
-sub _alias {
+sub _alias
+{
     my $import = shift;
-    if ((!$has_Compress_Zlib && !defined $gzip_external) || $gzip_external) {
-       # The undef *gzopen is really needed only during
-       # testing where we eval several 'use IO::Zlib's.
-       undef *gzopen;
-        *gzopen                 = \&gzopen_external;
-        *IO::Handle::gzread     = \&gzread_external;
-        *IO::Handle::gzwrite    = \&gzwrite_external;
+
+    if ($gzip_external || (!$has_Compress_Zlib && !defined($gzip_external)))
+    {
+        require IO::Handle;
+
+        undef *gzopen;
+        *gzopen = \&gzopen_external;
+
+        *IO::Handle::gzread = \&gzread_external;
+        *IO::Handle::gzwrite = \&gzwrite_external;
         *IO::Handle::gzreadline = \&gzreadline_external;
-        *IO::Handle::gzeof      = \&gzeof_external;
-        *IO::Handle::gzclose    = \&gzclose_external;
-       $gzip_used = 1;
-    } else {
-       croak "$import: no Compress::Zlib and no external gzip"
-           unless $has_Compress_Zlib;
-        *gzopen     = \&Compress::Zlib::gzopen;
-        *gzread     = \&Compress::Zlib::gzread;
-        *gzwrite    = \&Compress::Zlib::gzwrite;
+        *IO::Handle::gzeof = \&gzeof_external;
+        *IO::Handle::gzclose = \&gzclose_external;
+
+        $gzip_used = 1;
+    }
+    elsif ($has_Compress_Zlib)
+    {
+        *gzopen = \&Compress::Zlib::gzopen;
+        *gzread = \&Compress::Zlib::gzread;
+        *gzwrite = \&Compress::Zlib::gzwrite;
         *gzreadline = \&Compress::Zlib::gzreadline;
-        *gzeof      = \&Compress::Zlib::gzeof;
+        *gzeof = \&Compress::Zlib::gzeof;
+    }
+    else
+    {
+        croak "$import: no Compress::Zlib and no external gzip";
     }
+
     $aliased = 1;
 }
 
-sub import {
-    shift;
+sub import
+{
+    my $class = shift;
     my $import = "IO::Zlib::import";
-    if (@_) {
-       if (_import($import, @_)) {
-           croak "$import: '@_' is illegal";
-       }
+
+    if (@_)
+    {
+        if (_import($import, @_))
+        {
+            croak "$import: '@_' is illegal";
+        }
     }
+
     _alias($import);
 }
 
-@ISA = qw(Tie::Handle);
-
 sub TIEHANDLE
 {
     my $class = shift;
@@ -537,7 +576,7 @@ sub getlines
     my $self = shift;
 
     croak "IO::Zlib::getlines: must be called in list context"
-       unless wantarray;
+        unless wantarray;
 
     return tied(*{$self})->READLINE();
 }
@@ -559,89 +598,138 @@ sub AUTOLOAD
     return tied(*{$self})->$AUTOLOAD(@_);
 }
 
-sub gzopen_external {
-    my ($filename, $mode) = @_;
-    require IO::Handle;
+sub gzopen_external
+{
+    my $filename = shift;
+    my $mode = shift;
     my $fh = IO::Handle->new();
-    if ($mode =~ /r/) {
-       # Because someone will try to read ungzipped files
-       # with this we peek and verify the signature.  Yes,
-       # this means that we open the file twice (if it is
-       # gzipped).
-       # Plenty of race conditions exist in this code, but
-       # the alternative would be to capture the stderr of
-       # gzip and parse it, which would be a portability nightmare.
-       if (-e $filename && open($fh, $filename)) {
-           binmode $fh;
-           my $sig;
-           my $rdb = read($fh, $sig, 2);
-           if ($rdb == 2 && $sig eq "\x1F\x8B") {
-               my $ropen = sprintf $gzip_read_open, $filename;
-               if (open($fh, $ropen)) {
-                   binmode $fh;
-                   return $fh;
-               } else {
-                   return undef;
-               }
-           }
-           seek($fh, 0, SEEK_SET) or
-               die "IO::Zlib: open('$filename', 'r'): seek: $!";
-           return $fh;
-       } else {
-           return undef;
-       }
-    } elsif ($mode =~ /w/) {
-       my $level = '';
-       $level = "-$1" if $mode =~ /([1-9])/;
-       # To maximize portability we would need to open
-       # two filehandles here, one for "| gzip $level"
-       # and another for "> $filename", and then when
-       # writing copy bytes from the first to the second.
-       # We are using IO::Handle objects for now, however,
-       # and they can only contain one stream at a time.
-       my $wopen = sprintf $gzip_write_open, $filename;
-       if (open($fh, $wopen)) {
-           $fh->autoflush(1);
-           binmode $fh;
-           return $fh;
-       } else {
-           return undef;
-       }
-    } else {
-       croak "IO::Zlib::gzopen_external: mode '$mode' is illegal";
+
+    if ($mode =~ /r/)
+    {
+        # Because someone will try to read ungzipped files
+        # with this we peek and verify the signature.  Yes,
+        # this means that we open the file twice (if it is
+        # gzipped).
+        # Plenty of race conditions exist in this code, but
+        # the alternative would be to capture the stderr of
+        # gzip and parse it, which would be a portability nightmare.
+        if (-e $filename && open($fh, $filename))
+        {
+            binmode $fh;
+
+            my $sig;
+            my $rdb = read($fh, $sig, 2);
+
+            if ($rdb == 2 && $sig eq "\x1F\x8B")
+            {
+                my $ropen = sprintf($gzip_read_open, $filename);
+
+                if (open($fh, $ropen))
+                {
+                    binmode $fh;
+
+                    return $fh;
+                }
+                else
+                {
+                    return undef;
+                }
+            }
+
+            seek($fh, 0, SEEK_SET) or
+                die "IO::Zlib: open('$filename', 'r'): seek: $!";
+
+            return $fh;
+        }
+        else
+        {
+            return undef;
+        }
     }
+    elsif ($mode =~ /w/)
+    {
+        my $level = $mode =~ /([1-9])/ ? "-$1" : "";
+
+        # To maximize portability we would need to open
+        # two filehandles here, one for "| gzip $level"
+        # and another for "> $filename", and then when
+        # writing copy bytes from the first to the second.
+        # We are using IO::Handle objects for now, however,
+        # and they can only contain one stream at a time.
+        my $wopen = sprintf($gzip_write_open, $filename);
+
+        if (open($fh, $wopen))
+        {
+            $fh->autoflush(1);
+            binmode $fh;
+
+            return $fh;
+        }
+        else
+        {
+            return undef;
+        }
+    }
+    else
+    {
+        croak "IO::Zlib::gzopen_external: mode '$mode' is illegal";
+    }
+
     return undef;
 }
 
-sub gzread_external {
-    # Use read() instead of syswrite() because people may
+sub gzread_external
+{
+    my $file = shift;
+    my $bufref = \$_[0];
+    my $nbytes = $_[1] || 4096;
+
+    # Use read() instead of sysread() because people may
     # mix reads and readlines, and we don't want to mess
     # the stdio buffering.  See also gzreadline_external()
     # and gzwrite_external().
-    my $nread = read($_[0], $_[1], @_ == 3 ? $_[2] : 4096);
-    defined $nread ? $nread : -1;
+    my $nread = read($file, $$bufref, $nbytes);
+
+    return defined $nread ? $nread : -1;
 }
 
-sub gzwrite_external {
+sub gzwrite_external
+{
+    my $file = shift;
+    my $buf = shift;
+
     # Using syswrite() is okay (cf. gzread_external())
     # since the bytes leave this process and buffering
     # is therefore not an issue.
-    my $nwrote = syswrite($_[0], $_[1]);
-    defined $nwrote ? $nwrote : -1;
+    my $nwrote = syswrite($file, $buf);
+
+    return defined $nwrote ? $nwrote : -1;
 }
 
-sub gzreadline_external {
+sub gzreadline_external
+{
+    my $file = shift;
+    my $bufref = \$_[0];
+
     # See the comment in gzread_external().
-    $_[1] = readline($_[0]);
-    return defined $_[1] ? length($_[1]) : -1;
+    $$bufref = readline($file);
+
+    return defined $$bufref ? length($$bufref) : -1;
 }
 
-sub gzeof_external {
-    return eof($_[0]);
+sub gzeof_external
+{
+    my $file = shift;
+
+    return eof($file);
 }
 
-sub gzclose_external {
-    close($_[0]);
+sub gzclose_external
+{
+    my $file = shift;
+
+    close($file);
+
     # I am not entirely certain why this is needed but it seems
     # the above close() always fails (as if the stream would have
     # been already closed - something to do with using external
index 80aed9c..c689a04 100644 (file)
@@ -1,31 +1,34 @@
+use strict;
+use warnings;
+
 use IO::Zlib;
 
 sub ok
 {
     my ($no, $ok) = @_ ;
-
-    #++ $total ;
-    #++ $totalBad unless $ok ;
-
     print "ok $no\n" if $ok ;
     print "not ok $no\n" unless $ok ;
 }
 
-$name="test.gz";
+my $name = "test.gz";
 
 print "1..17\n";
 
-$hello = <<EOM ;
+my $hello = <<EOM ;
 hello world
 this is a test
 EOM
 
+my $file;
+
 ok(1, $file = IO::Zlib->new($name, "wb"));
 ok(2, $file->print($hello));
 ok(3, $file->opened());
 ok(4, $file->close());
 ok(5, !$file->opened());
 
+my $uncomp;
+
 ok(6, $file = IO::Zlib->new());
 ok(7, $file->open($name, "rb"));
 ok(8, !$file->eof());
index 1d90d7f..7a9988a 100644 (file)
@@ -1,3 +1,15 @@
+use strict;
+use warnings;
+
+use IO::Zlib;
+
+sub ok
+{
+    my ($no, $ok) = @_ ;
+    print "ok $no\n" if $ok ;
+    print "not ok $no\n" unless $ok ;
+}
+
 # Test this only iff we have an executable /usr/bin/gzip
 # AND we have /usr/bin in our PATH
 # AND we have a useable /usr/bin directory.
 
 my $gzip = "/usr/bin/gzip";
 
-unless-x $gzip &&
+unless (-x $gzip &&
         ":$ENV{PATH}:" =~ m!:/usr/bin:! &&
-        -d "/usr/bin" && -x "/usr/bin") {
+        -d "/usr/bin" && -x "/usr/bin")
+{
     print "1..0 # Skip: no $gzip\n";
     exit 0;
 }
 
-sub ok
-{
-    my ($no, $ok) = @_ ;
-    print "ok $no\n" if $ok ;
-    print "not ok $no\n" unless $ok ;
-}
-
 my $hasCompressZlib;
 
 BEGIN {
@@ -27,92 +33,78 @@ BEGIN {
     $hasCompressZlib = $@ ? 0 : 1;
 }
 
-use IO::Zlib;
+print "1..35\n";
 
-print "1..33\n";
-
-# Other export functionality (none) is tested in import.t.
-
-ok(1,
-   $hasCompressZlib == IO::Zlib::has_Compress_Zlib());
+ok(1, $hasCompressZlib == IO::Zlib::has_Compress_Zlib());
 
 eval "use IO::Zlib qw(:gzip_external)";
-ok(2,
-   $@ =~ /^IO::Zlib::import: ':gzip_external' requires an argument /);
-
-eval "use IO::Zlib";
-ok(3, !$@);
 
-ok(4,
-   $hasCompressZlib || IO::Zlib::gzip_used());
+ok(2, $@ =~ /^IO::Zlib::import: ':gzip_external' requires an argument /);
 
-ok(5,
-   !defined IO::Zlib::gzip_external());
-
-ok(6,
-   IO::Zlib::gzip_read_open() eq 'gzip -dc %s |');
-
-ok(7,
-   IO::Zlib::gzip_write_open() eq '| gzip > %s');
+eval "use IO::Zlib";
 
-ok(8,
-   ($hasCompressZlib && \&IO::Zlib::gzopen == \&Compress::Zlib::gzopen) ||
-   \&IO::Zlib::gzopen == \&IO::Zlib::gzopen_external);
+ok(3, !$@);
+ok(4, $hasCompressZlib || IO::Zlib::gzip_used());
+ok(5, !defined IO::Zlib::gzip_external());
+ok(6, IO::Zlib::gzip_read_open() eq 'gzip -dc %s |');
+ok(7, IO::Zlib::gzip_write_open() eq '| gzip > %s');
+ok(8, \&IO::Zlib::gzopen == \&IO::Zlib::gzopen_external ||
+      ($hasCompressZlib && \&IO::Zlib::gzopen == \&Compress::Zlib::gzopen));
 
 eval "use IO::Zlib qw(:gzip_external 0)";
 
-ok(9,
-   !IO::Zlib::gzip_external());
-
-ok(10,
-   ($hasCompressZlib && \&IO::Zlib::gzopen == \&Compress::Zlib::gzopen) ||
-   (!$hasCompressZlib &&
-    $@ =~ /^IO::Zlib::import: no Compress::Zlib and no external gzip /));
+ok(9, !IO::Zlib::gzip_external());
+ok(10, ($hasCompressZlib && \&IO::Zlib::gzopen == \&Compress::Zlib::gzopen) ||
+       (!$hasCompressZlib && $@ =~ /^IO::Zlib::import: no Compress::Zlib and no external gzip /));
 
 eval "use IO::Zlib qw(:gzip_external 1)";
 
-ok(11,
-   IO::Zlib::gzip_used());
-
-ok(12,
-   IO::Zlib::gzip_external());
-
-ok(13,
-   \&IO::Zlib::gzopen == \&IO::Zlib::gzopen_external);
+ok(11, IO::Zlib::gzip_used());
+ok(12, IO::Zlib::gzip_external());
+ok(13, \&IO::Zlib::gzopen == \&IO::Zlib::gzopen_external);
 
 eval 'IO::Zlib->new("foo", "xyz")';
+
 ok(14, $@ =~ /^IO::Zlib::gzopen_external: mode 'xyz' is illegal /);
 
 # The following is a copy of the basic.t, shifted up by 14 tests,
 # the difference being that now we should be using the external gzip.
 
-$name="test.gz";
+my $name="test.gz";
 
-$hello = <<EOM ;
+my $hello = <<EOM ;
 hello world
 this is a test
 EOM
 
+my $file;
+
 ok(15, $file = IO::Zlib->new($name, "wb"));
 ok(16, $file->print($hello));
 ok(17, $file->opened());
 ok(18, $file->close());
 ok(19, !$file->opened());
 
+my $uncomp;
+
 ok(20, $file = IO::Zlib->new());
 ok(21, $file->open($name, "rb"));
 ok(22, !$file->eof());
 ok(23, $file->read($uncomp, 1024) == length($hello));
-ok(24, $file->eof());
-ok(25, $file->opened());
-ok(26, $file->close());
-ok(27, !$file->opened());
+ok(24, $uncomp eq $hello);
+ok(25, $file->eof());
+ok(26, $file->opened());
+ok(27, $file->close());
+ok(28, !$file->opened());
 
-unlink($name);
+$file = IO::Zlib->new($name, "rb");
+ok(29, $file->read($uncomp, 1024, length($uncomp)) == length($hello));
+ok(30, $uncomp eq $hello . $hello);
+$file->close();
 
-ok(28, $hello eq $uncomp);
+unlink($name);
 
-ok(29, !defined(IO::Zlib->new($name, "rb")));
+ok(31, !defined(IO::Zlib->new($name, "rb")));
 
 # Then finally test modifying the open commands.
 
@@ -120,23 +112,18 @@ my $new_read = 'gzip.exe /d /c %s |';
 
 eval "use IO::Zlib ':gzip_read_open' => '$new_read'";
 
-ok(30,
-   IO::Zlib::gzip_read_open() eq $new_read);
+ok(32, IO::Zlib::gzip_read_open() eq $new_read);
 
 eval "use IO::Zlib ':gzip_read_open' => 'bad'";
 
-ok(31,
-   $@ =~ /^IO::Zlib::import: ':gzip_read_open' 'bad' is illegal /);
+ok(33, $@ =~ /^IO::Zlib::import: ':gzip_read_open' 'bad' is illegal /);
 
 my $new_write = '| gzip.exe %s';
 
 eval "use IO::Zlib ':gzip_write_open' => '$new_write'";
 
-ok(32,
-   IO::Zlib::gzip_write_open() eq $new_write);
+ok(34, IO::Zlib::gzip_write_open() eq $new_write);
 
 eval "use IO::Zlib ':gzip_write_open' => 'bad'";
 
-ok(33,
-   $@ =~ /^IO::Zlib::import: ':gzip_write_open' 'bad' is illegal /);
-
+ok(35, $@ =~ /^IO::Zlib::import: ':gzip_write_open' 'bad' is illegal /);
index 2424d5b..3181ace 100644 (file)
@@ -1,21 +1,21 @@
+use strict;
+use warnings;
+
 use IO::Zlib;
 
 sub ok
 {
     my ($no, $ok) = @_ ;
-
-    #++ $total ;
-    #++ $totalBad unless $ok ;
-
     print "ok $no\n" if $ok ;
     print "not ok $no\n" unless $ok ;
 }
 
-$name="test.gz";
+my $name = "test.gz";
 
 print "1..10\n";
 
-$text = "abcd";
+my $text = "abcd";
+my $file;
 
 ok(1, $file = IO::Zlib->new($name, "wb"));
 ok(2, $file->print($text));
index fed17da..6ba5b47 100644 (file)
@@ -1,21 +1,20 @@
+use strict;
+use warnings;
+
 use IO::Zlib;
 
 sub ok
 {
     my ($no, $ok) = @_ ;
-
-    #++ $total ;
-    #++ $totalBad unless $ok ;
-
     print "ok $no\n" if $ok ;
     print "not ok $no\n" unless $ok ;
 }
 
-$name="test.gz";
+my $name = "test.gz";
 
 print "1..23\n";
 
-@text = (<<EOM, <<EOM, <<EOM, <<EOM) ;
+my @text = (<<EOM, <<EOM, <<EOM, <<EOM) ;
 this is line 1
 EOM
 the second line
@@ -25,7 +24,8 @@ EOM
 the final line
 EOM
 
-$text = join("", @text) ;
+my $text = join("", @text) ;
+my $file;
 
 ok(1, $file = IO::Zlib->new($name, "wb"));
 ok(2, $file->print($text));
@@ -41,6 +41,8 @@ ok(10, !defined($file->getline()));
 ok(11, $file->eof());
 ok(12, $file->close());
 
+my @lines;
+
 ok(13, $file = IO::Zlib->new($name, "rb"));
 ok(14, !$file->eof());
 eval '$file->getlines';
index 336d80a..ddb591f 100644 (file)
@@ -1,3 +1,6 @@
+use strict;
+use warnings;
+
 print "1..1\n";
 
 sub ok
@@ -10,4 +13,5 @@ sub ok
 # The :gzip tags are tested in external.t.
 
 eval "use IO::Zlib qw(foo bar)";
+
 ok(1, $@ =~ /^IO::Zlib::import: 'foo bar' is illegal /);
index 0203182..25852df 100644 (file)
@@ -1,31 +1,34 @@
+use strict;
+use warnings;
+
 use IO::Zlib;
 
 sub ok
 {
     my ($no, $ok) = @_ ;
-
-    #++ $total ;
-    #++ $totalBad unless $ok ;
-
     print "ok $no\n" if $ok ;
     print "not ok $no\n" unless $ok ;
 }
 
-$name="test.gz";
+my $name = "test.gz";
 
 print "1..7\n";
 
-$contents = "";
+my $contents = "";
 
 foreach (1 .. 5000)
 {
      $contents .= chr(int(rand(255)));
 }
 
+my $file;
+
 ok(1, $file = IO::Zlib->new($name, "wb"));
 ok(2, $file->print($contents));
 ok(3, $file->close());
 
+my $uncomp;
+
 ok(4, $file = IO::Zlib->new($name, "rb"));
 ok(5, $file->read($uncomp, 8192) == length($contents));
 ok(6, $file->close());
index 029b282..07f8861 100644 (file)
@@ -1,21 +1,20 @@
+use strict;
+use warnings;
+
 use IO::Zlib;
 
 sub ok
 {
     my ($no, $ok) = @_ ;
-
-    #++ $total ;
-    #++ $totalBad unless $ok ;
-
     print "ok $no\n" if $ok ;
     print "not ok $no\n" unless $ok ;
 }
 
-$name="test.gz";
+my $name = "test.gz";
 
 print "1..11\n";
 
-$hello = <<EOM ;
+my $hello = <<EOM ;
 hello world
 this is a test
 EOM
@@ -25,6 +24,8 @@ ok(2, printf OUT "%s - %d\n", "hello", 123);
 ok(3, print OUT $hello);
 ok(4, untie *OUT);
 
+my $uncomp;
+
 ok(5, tie *IN, "IO::Zlib", $name, "rb");
 ok(6, !eof IN);
 ok(7, <IN> eq "hello - 123\n");
index 884af47..734b46c 100644 (file)
@@ -1,33 +1,38 @@
+use strict;
+use warnings;
+
 use IO::Zlib;
 
 sub ok
 {
     my ($no, $ok) = @_ ;
-
-    #++ $total ;
-    #++ $totalBad unless $ok ;
-
     print "ok $no\n" if $ok ;
     print "not ok $no\n" unless $ok ;
 }
 
 print "1..10\n";
 
-$hello = <<EOM ;
+my $hello = <<EOM ;
 hello world
 this is a test
 EOM
 
-$name = "test$$";
+my $name = "test$$";
 
-if (open(FH, ">$name")) {
+if (open(FH, ">$name"))
+{
     binmode FH;
     print FH $hello;
     close FH;
-} else {
+}
+else
+{
     die "$name: $!";
 }
 
+my $file;
+my $uncomp;
+
 ok(1, $file = IO::Zlib->new());
 ok(2, $file->open($name, "rb"));
 ok(3, !$file->eof());
@@ -42,4 +47,3 @@ unlink($name);
 ok(9, $hello eq $uncomp);
 
 ok(10, !defined(IO::Zlib->new($name, "rb")));
-
index e760fde..182b962 100644 (file)
@@ -1,33 +1,38 @@
+use strict;
+use warnings;
+
 require IO::Zlib; # uncomp2.t is like uncomp1.t but without 'use'
 
 sub ok
 {
     my ($no, $ok) = @_ ;
-
-    #++ $total ;
-    #++ $totalBad unless $ok ;
-
     print "ok $no\n" if $ok ;
     print "not ok $no\n" unless $ok ;
 }
 
 print "1..10\n";
 
-$hello = <<EOM ;
+my $hello = <<EOM ;
 hello world
 this is a test
 EOM
 
-$name = "test$$";
+my $name = "test$$";
 
-if (open(FH, ">$name")) {
+if (open(FH, ">$name"))
+{
     binmode FH;
     print FH $hello;
     close FH;
-} else {
+}
+else
+{
     die "$name: $!";
 }
 
+my $file;
+my $uncomp;
+
 ok(1, $file = IO::Zlib->new());
 ok(2, $file->open($name, "rb"));
 ok(3, !$file->eof());