Article 21486 of comp.lang.perl.misc:
Path: nntp1.best.com!news1.best.com!news.exodus.net!imci4!imci3!imci2!news.internetMCI.com!newsfeed.internetmci.com!news.mathworks.com!uunet!in1.uu.net!spstimes.sps.mot.com!newsdist.sps.mot.com!risc.sps.mot.com!talos4!dwolfe
From:
[email protected] (Dave Wolfe)
Newsgroups: comp.lang.perl.misc
Subject: ftplib.pl bug and fix
Date: 29 Feb 96 17:53:21 GMT
Organization: Motorola (Austin,TX)
Lines: 39
Message-ID: <dwolfe.825616401@talos4>
Reply-To: Dave Wolfe <
[email protected]>
NNTP-Posting-Host: miaow.sps.mot.com
Since mail to the author of ftplib.pl (David Sundstrom
<
[email protected]>) bounces, I'll post here to let other ftplib.pl
users know and to Perl5-porters in hopes that someone will update the
CPAN copy (scripts/ftpstuff/ftplib-1.1.pl.Z).
I discovered that ftplib.pl (1.1) drops null lines sometimes during an
ASCII mode get. The easiest test case is a small file (< 1024 bytes)
with several trailing null lines. This happens because of the way split
works when the limit parameter isn't specified. Here's my patch:
*** ftplib.pl.orig Wed Jun 14 10:39:20 1995
--- ftplib.pl Thu Feb 29 10:17:45 1996
***************
*** 222,229 ****
last unless($len=sysread(DATA,$buf,1024));
if($Ascii) {
substr($buf,0,0)=$partial; ## prepend from last sysread
! @buf=split(/\r?\n/,$buf); ## break into lines
! if ($buf=~/\n$/) { $partial=''; } else { $partial=pop(@buf); }
foreach(@buf) { print DFILE $_,"\n"; }
} else {
last unless ( (syswrite(DFILE,$buf,$len)==$len) );
--- 222,229 ----
last unless($len=sysread(DATA,$buf,1024));
if($Ascii) {
substr($buf,0,0)=$partial; ## prepend from last sysread
! @buf=split(/\r?\n/,$buf,1024); ## break into lines
! $partial=pop(@buf);
foreach(@buf) { print DFILE $_,"\n"; }
} else {
last unless ( (syswrite(DFILE,$buf,$len)==$len) );
--
Dave Wolfe *Not a spokesman for Motorola*
Motorola MMTG 6501 Wm. Cannon Dr. W. OE112 Austin TX 78735-8598
--
Dave Wolfe *Not a spokesman for Motorola*
Motorola MMTG 6501 Wm. Cannon Dr. W. OE112 Austin TX 78735-8598