Skip Menu |

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 8696
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: DANKOGAI [...] cpan.org
Requestors: GAAS [...] cpan.org
Cc:
AdminCc:

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



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
Thanks, applied. Dan the Encode Maintainer