diff options
author | Slaven Rezic <slaven@rezic.de> | 2002-09-11 21:37:09 +0200 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-09-26 07:46:43 +0000 |
commit | 718842b0e14b2d067314bf35e22eac61894424e9 (patch) | |
tree | 8784f808b8e8db1542b5139e615deb7fdbbf112a | |
parent | 7fef744d4001fa86c45f1d45805860ed8598b95a (diff) | |
download | perl-718842b0e14b2d067314bf35e22eac61894424e9.tar.gz |
Re: [perl #17141] Text::Wrap "this should not happen" message
Message-ID: <871y80a0my.fsf@vran.herceg.de>
p4raw-id: //depot/perl@17917
-rwxr-xr-x | lib/Text/TabsWrap/t/wrap.t | 8 | ||||
-rw-r--r-- | lib/Text/Wrap.pm | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/Text/TabsWrap/t/wrap.t b/lib/Text/TabsWrap/t/wrap.t index fee6ce070d..369512d27e 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 8dd1f6c251..2327666038 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<Example 3> C<Text::Wrap::wrap()> 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. |