Subject: | while (defined(read )) { ... } is an infinite loop |
read() will continue to return 0 at EOF and 0 is defined.
It also seems strange to call the variable where the decoded
string is accumulated $utf8.
Attached patch is a suggested fix.
--- Encode-2.08/Encode.pm 2004-10-24 15:00:39.000000000 +0200
+++ Encode-2.08-hacked/Encode.pm 2004-12-01 18:56:05.952274481 +0100
@@ -600,12 +600,10 @@
(i.e. you are reading with a fixed-width buffer). Here is a sample
code that does exactly this:
- my $data = ''; my $utf8 = '';
- while(defined(read $fh, $buffer, 256)){
- # buffer may end in a partial character so we append
- $data .= $buffer;
- $utf8 .= decode($encoding, $data, Encode::FB_QUIET);
- # $data now contains the unprocessed partial character
+ my $buffer = ''; my $string = '';
+ while(read $fh, $buffer, 256, length($buffer)){
+ $string .= decode($encoding, $buffer, Encode::FB_QUIET);
+ # $buffer now contains the unprocessed partial character
}
=item I<CHECK> = Encode::FB_WARN