Subject: Bug#638950: libtext-wrapi18n-perl: Attaching a possible patch. It's my first patch, I hope do it right.

From: David Arroyo Menéndez <[email-masked]>
Date: Fri, 23 Sep 2011 17:27:33 +0200

Package: libtext-wrapi18n-perl
Version: 0.06-7
Followup-For: Bug #638950

Dear Maintainer,
*** Please consider answering these questions, where appropiate ***

   * What led up to the situation? 

Upgrading from a clean squeeze to testing with apt-get -u dist-upgrade

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

IYou can see my solution with my diff -u between files:

--- WrapI18N.pm	2003-06-25 11:14:25.000000000 +0200
+++ /usr/share/perl5/Text/WrapI18N.pm	2011-09-23 14:21:25.000000000 +0200
@@ -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;
@@ -98,7 +98,11 @@
 			# the current word is too long to fit a line
 			$out .= $word . $separator;
 			$len = 0;
-			$text = $top2 . $c . $text;
+			if ($text) {
+			    $text = $top2 . $c . $text;
+			} else {
+			    $text = $top2 . $c;
+			}
 			$word = ''; $wlen = 0;
 		}
 	}
@@ -127,7 +131,11 @@
 		return ('?', substr($string,1), 1, 0);
 	}
 	$c = substr($string, 0, $l);
-	$r = substr($string, $l);
+	if substr($string, $l) {
+	    $r = substr($string, $l);
+	} else {
+	    $r = '';
+	}
 	$w = mbswidth($c);
 
 	if (!defined($charmap)) {

   * What was the outcome of this action?

The package was installed successfully

   * What outcome did you expect instead?

*** End of the template - remove these lines ***

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 3.0.0-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=es_ES.utf8, LC_CTYPE=es_ES.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libtext-wrapi18n-perl depends on:
ii  libtext-charwidth-perl  0.04-7

libtext-wrapi18n-perl recommends no packages.

libtext-wrapi18n-perl suggests no packages.

-- no debconf information