From: Slaven Rezic Date: Wed, 11 Sep 2002 19:37:09 +0000 (+0200) Subject: Re: [perl #17141] Text::Wrap "this should not happen" message X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=718842b0e14b2d067314bf35e22eac61894424e9;hp=7fef744d4001fa86c45f1d45805860ed8598b95a;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #17141] Text::Wrap "this should not happen" message Message-ID: <871y80a0my.fsf@vran.herceg.de> p4raw-id: //depot/perl@17917 --- diff --git a/lib/Text/TabsWrap/t/wrap.t b/lib/Text/TabsWrap/t/wrap.t index fee6ce0..369512d 100755 --- a/lib/Text/TabsWrap/t/wrap.t +++ b/lib/Text/TabsWrap/t/wrap.t @@ -122,7 +122,7 @@ DONE $| = 1; -print "1..", 1 +@tests, "\n"; +print "1..", 2 +@tests, "\n"; use Text::Wrap; @@ -207,3 +207,9 @@ my $w = wrap('zzz','yyy',$tw); print (($w eq "zzz$tw") ? "ok $tn\n" : "not ok $tn"); $tn++; +{ + local $Text::Wrap::columns = 10; + local $Text::Wrap::huge = "wrap"; + print ((wrap("verylongindent", "", "foo") eq "verylongindent\nfoo") ? "ok $tn\n" : "not ok $tn"); + $tn++; +} diff --git a/lib/Text/Wrap.pm b/lib/Text/Wrap.pm index 8dd1f6c..2327666 100644 --- a/lib/Text/Wrap.pm +++ b/lib/Text/Wrap.pm @@ -34,6 +34,7 @@ sub wrap my $t = expand(join("", (map { /\s+\z/ ? ( $_ ) : ($_, ' ') } @t), $tail)); my $lead = $ip; my $ll = $columns - length(expand($ip)) - 1; + $ll = 0 if $ll < 0; my $nll = $columns - length(expand($xp)) - 1; my $nl = ""; my $remainder = ""; @@ -144,7 +145,7 @@ B C is a very simple paragraph formatter. It formats a single paragraph at a time by breaking lines at word boundries. Indentation is controlled for the first line (C<$initial_tab>) and -all subsquent lines (C<$subsequent_tab>) independently. Please note: +all subsequent lines (C<$subsequent_tab>) independently. Please note: C<$initial_tab> and C<$subsequent_tab> are the literal strings that will be used: it is unlikley you would want to pass in a number.