[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] cpan-mac



Stephen, we have been having problems with Archive::Tar.  The summary is
below.  You can email me and Paul, or the list, if you need more
clarification.


At 18:47 -0400 2000.09.13, Paul Schinder wrote:
>I stared at the diff between 0.21 and 0.22 for a while and nothing
>jumped out at me as the likely culprit, unless it's this.  I noticed
>that 0.22 uses Compress::Zlib::gdzopen_ instead of
>Compress::Zlib::gzopen.  Do I remember right that gdzopen was the
>thing that didn't work in Compress::Zlib?  If so, could some rogue
>pointer be trashing something?

Hm.  I notice the old code in Archive::Tar 0.21 used gzopen(), but it isn't
that simple.  gzopen() tests its input to see if it is a filehandle, and if
so, passes it on to gzdopen_() anyway.

So I played around some more, and I saw this:

    if ($^O eq "MSWin32") {
	$fh = $_[0];
    }
    else {
	$fh = fcntl ($_[0], F_DUPFD, 0)
	    or goto &_drat;
    }

It used to be that jus $_[0] was used, and passed to gzopen().  Now, $_[0]
was a filehandle ... for some reason it "worked" anyway.  I went back and
looked, and the problem with gzdopen is not that it doesn't work at all,
but that it has problems if the entire file is not your gzip data.  The
only Compress::Zlib tests that fail are those that mix gzipped and
non-gzipped data in the same file.  So if you used the whole file, you were
fine.  So gzdopen is not our problem.

Anyway, looking at gzopen(), if $_[0] is a filehandle, it calls
gzdopen_(fileno($fh), $mode, tell($fh)).  The call to gzdopen_ in
Archive::Tar leaves off the fileno() ... I guess fcntl() is returning the
actual fd, so fileno() is unnecessary.

Sure enough, if I add this:

    elsif ($^O eq "MacOS") {
	$fh = fileno($_[0]);
    }

it appears to work.  So for some reason, it appears the call to fnctl is
failing.  I don't know if this is OK, though; I am not sure why Stephen
dup'd the fd instead of just getting the fd with fileno().  I am CC'ing
author, and will include 0.21 for now, since I just want to get cpan-mac
out now, and 0.21 seems to be fine.  I'll keep using Archive::Tar with the
above modification on my own box for now.

Thanks,

-- 
Chris Nandor                      pudge@pobox.com    http://pudge.net/
Open Source Development Network    pudge@osdn.com     http://osdn.com/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org