Skip Menu |

This queue is for tickets about the Text-WrapI18N CPAN distribution.

Report information
The Basics
Id: 42102
Status: new
Priority: 0/
Queue: Text-WrapI18N

People
Owner: Nobody in particular
Requestors: he [...] NetBSD.org
Cc:
AdminCc:

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



Subject: Text::WrapI18N looping on "problematical input"
Date: Fri, 02 Jan 2009 16:09:56 +0100 (CET)
To: bug-Text-WrapI18N [...] rt.cpan.org
From: Havard Eidnes <he [...] NetBSD.org>
Hi, after asking about a problem related to Debian's po4a, which manifests itself as "endless loops" while building their dpkg package, I got pointed in this direction by the kind Debian folks, since they indicated that Text::WrapI18N was actually the source of the problem. They even have a test (which could be refined to use a small CPU time resource limit, and test if it's tripped) and a suggested patch, both attached below for your convenience. The Debian problem report can be seen at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470250 Without the fix, test.pl will spin endlessly or until virtual memory runs out, with the patch, it promptly completes. Best regards, - HÃ¥vard
#!/usr/bin/perl use Text::WrapI18N; print "step 1\n"; print Text::WrapI18N::wrap('', ' ', '123 567 901 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); print "\n"; print "step 2\n"; print Text::WrapI18N::wrap('', ' ', '123 567 901 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); print "\n"; print "step 3\n"; print Text::WrapI18N::wrap('', ' ', '123 567 901 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); print "\n"; print "step 3\n"; print Text::WrapI18N::wrap('', ' ', '123 567 901 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); print "\n"; print "step 3\n";
--- /usr/share/perl5/Text/WrapI18N.pm.org 2003-06-25 11:14:25.000000000 +0200 +++ /usr/share/perl5/Text/WrapI18N.pm 2008-03-13 02:04:02.628000837 +0100 @@ -88,7 +88,7 @@ $len = 0; $text = $top2 . $text; $word = ''; $wlen = 0; - } elsif ($wlen + $w <= $columns) { + } elsif ($wlen + $w <= $columns - length ($top2)) { # the current word is sent to next line $out .= $separator; $len = 0;