Skip Menu |
 

This queue is for tickets about the IO-Compress CPAN distribution.

Report information
The Basics
Id: 67554
Status: resolved
Priority: 0/
Queue: IO-Compress

People
Owner: Nobody in particular
Requestors: fuzz [...] namm.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.030
Fixed in: 2.034



Subject: Behavior of eof with empty files is different from the normal IO::File->eof()
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1303119725-18805-38"
Content-Length: 0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 876
Download (untitled) / with headers
text/plain 876b
I've noticed a slightly little difference between the handling of empty files from IO::File and IO::Uncompress::(Gunzip||Bunzip2). Empty files don't return a eof at once after opening an empty file. Here's some pseudocode: touch empty ; gzip empty $handle = IO::Uncompress::Gunzip->new( 'empty.gz '); print $handle->eof(); # prints 0, should be 1 print $handle->getline(); # prints empty string, should be undef Here's the behavior with IO::File: touch empty $handle = IO::File->new( 'empty'); print $handle->eof(); # prints true print $handle->getline(); # produces undefined warning I've attached a sample script that will print the above values. Here the mini usage for this script: 1) touch empty ; gzip empty ; touch empty 2) perl uncompress-bug.pl empty ; perl uncompress-bug.pl empty.gz Then you will notice the difference in the output. Thanks for your work.
Subject: uncompress-bug.pl
MIME-Version: 1.0
Content-Type: text/x-perl; name="uncompress-bug.pl"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="uncompress-bug.pl"
Content-Transfer-Encoding: binary
Content-Length: 795
Download uncompress-bug.pl
text/x-perl 795b
#!/usr/bin/perl use strict; use warnings; use IO::Uncompress::Gunzip; use IO::Uncompress::Bunzip2; use IO::File; my $filename = shift || die; my $line; my $handle; if ($filename =~ /.gz$/ ) { $handle = IO::Uncompress::Gunzip->new( $filename ); } elsif ($filename =~ /.bz2$/ ) { $handle = IO::Uncompress::Bunzip2->new( $filename ); } else { $handle = IO::File->new( $filename ) } printf "eof .... : %s\n", $handle->eof() ? 1 : 0; print "\n"; print "reading...\n\n"; $line = <$handle>; printf "eof .... : %s\n", $handle->eof() ? 1 : 0; printf "line ... : %s\n", defined $line ? 'defined' : 'undefined'; print "\n"; print "reading...\n\n"; $line = <$handle>; printf "eof .... : %s\n", $handle->eof() ? 1 : 0; printf "line ... : %s\n", defined $line ? 'defined' : 'undefined';
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-18812-1303157282-1946.67554-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 143
Download (untitled) / with headers
text/plain 143b
Hi Erik, thanks for the bug report. even better you provided a script to trigger the bug. I've reproduced it here. Working on a fix now. Paul


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.