diff options
author | Michael G. Schwern <schwern@pobox.com> | 2001-01-26 04:28:31 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-01-26 15:03:23 +0000 |
commit | 0110aa014f97741d8a9f48382bd97bfc15d8cd60 (patch) | |
tree | 57693c0b11bd7360b48ae708c410fafa85de8999 /lib/Text | |
parent | c52f9dcd042177cd20ef53fca007b7305fd4972f (diff) | |
download | perl-0110aa014f97741d8a9f48382bd97bfc15d8cd60.tar.gz |
(Retracted by #8573)
Subject: [PATCH Text::Wrap 2000.06292219] Spurious leading whitespace
Message-ID: <20010126092831.A15328@blackrider.aocn.com>
p4raw-id: //depot/perl@8552
Diffstat (limited to 'lib/Text')
-rw-r--r-- | lib/Text/Wrap.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Text/Wrap.pm b/lib/Text/Wrap.pm index 04efe19296..9241dfc7d3 100644 --- a/lib/Text/Wrap.pm +++ b/lib/Text/Wrap.pm @@ -25,7 +25,9 @@ sub wrap my ($ip, $xp, @t) = @_; my $r = ""; - my $t = expand(join(" ",@t)); + + my $t = _linearize(@t); + my $lead = $ip; my $ll = $columns - length(expand($ip)) - 1; my $nll = $columns - length(expand($xp)) - 1; @@ -61,6 +63,18 @@ sub wrap return $r; } +sub _linearize { + my @lines = expand(@_); + + # Join the lines together, adding in extra whitespace only where needed + # to keep words seperated. + my $text = join "", map { /\s+\Z/ ? $_ : $_.' ' } @lines[0..$#lines-1]; + $text .= $lines[-1]; + + return $text; +} + + sub fill { my ($ip, $xp, @raw) = @_; |