Subject: | IO::ScalarArray->getline does not return undef for EOF if undef($/) |
Using:
- perl, v5.8.0 built for i686-linux-thread-multi
- Gentoo Linux 1.4_rc2 (Linux lapi 2.4.19-gentoo-r7 #1 Tue Sep 17 20:37:30 CEST 2002 i686 GNU/Linux)
- IO-stringy-2.108
Detected when MIME encoding messages with:
- MIME-tools-5.411a
I tried to encode a quoted-printable MIME singlepart message (without parts) with MIM::Entity. The encoder hangs forever, waiting for non-existend data. The body of the message is stored in a MIME::Body::InCore object, using IO::ScalarArray to access the message lines. MIME::Decode::QuotPrint->encode_it does not detect EOF since no undef value is returned if $/ is not defined.
This behaviour can be tested with:
----------------------------------
#!/usr/bin/perl
use MIME::Entity;
$data = "A new message\n
to MIME encode.
The text is stored in one scalar value
but contains multiple lines, just like created
by MIME::Body::InCore->init\n";
IO::ScalarArray;
undef $/;
$AH = new IO::ScalarArray [ $data ];
while (defined($_ = $AH->getline)) {
print "Got line: $_" unless ($_ eq "");
}
$AH->close;
-----------------------------------
possible Solution: a patch is attached
Regards
Perolo Silantico
--- IO-stringy-2.108.orig/lib/IO/ScalarArray.pm 2003-03-11 11:21:42.000000000 +0100
+++ IO-stringy-2.108/lib/IO/ScalarArray.pm 2003-03-11 11:31:46.000000000 +0100
@@ -306,6 +306,8 @@
### Case 1: $/ is undef: slurp all...
if (!defined($/)) {
+ return undef if ($self->eof);
+
### Get the rest of the current string, followed by remaining strings:
my $ar = *$self->{AR};
my @slurp = (