From: Chip Salzenberg Date: Tue, 28 Jan 1997 11:10:44 +0000 (+1200) Subject: Refresh Text::Wrap to 97.011701 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68e56a5514edd0ab7f8a5f3ecd75c49a6ca1246e;p=p5sagit%2Fp5-mst-13.2.git Refresh Text::Wrap to 97.011701 --- diff --git a/lib/Text/Wrap.pm b/lib/Text/Wrap.pm index 96ccf7e..0910a2a 100644 --- a/lib/Text/Wrap.pm +++ b/lib/Text/Wrap.pm @@ -6,7 +6,7 @@ require Exporter; @EXPORT = qw(wrap); @EXPORT_OK = qw($columns); -$VERSION = 96.041801; +$VERSION = 97.011701; use vars qw($VERSION $columns $debug); use strict; @@ -16,7 +16,7 @@ BEGIN { $debug = 0; } -use Text::Tabs; +use Text::Tabs qw(expand unexpand); sub wrap { @@ -42,10 +42,15 @@ sub wrap $nl = $2; # repeat the above until there's none left - while ($t and $t =~ s/^([^\n]{0,$ll})(\s|\Z(?!\n))//xm) { - print "\$2 is '$2'\n" if $debug; - $nl = $2; - $r .= unexpand("\n" . $lead . $1); + while ($t) { + if ( $t =~ s/^([^\n]{0,$ll})(\s|\Z(?!\n))//xm ) { + print "\$2 is '$2'\n" if $debug; + $nl = $2; + $r .= unexpand("\n" . $lead . $1); + } elsif ($t =~ s/^([^\n]{$ll})//) { + $nl = "\n"; + $r .= unexpand("\n" . $lead . $1); + } } $r .= $nl; } @@ -63,9 +68,8 @@ sub wrap return $r; } - 1; -__DATA__ +__END__ =head1 NAME @@ -94,6 +98,12 @@ should be set to the full width of your output device. print wrap("\t","","This is a bit of text that forms a normal book-style paragraph"); +=head1 BUGS + +It's not clear what the correct behavior should be when Wrap() is +presented with a word that is longer than a line. The previous +behavior was to die. Now the word is split at line-length. + =head1 AUTHOR David Muir Sharnoff with help from Tim Pierce and @@ -101,6 +111,8 @@ others. =cut +Latest change by Andreas Koenig - 1/17/97 + print fill($initial_tab, $subsequent_tab, @text); print fill("", "", `cat book`);