summaryrefslogtreecommitdiff
path: root/lib/Text
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1997-01-28 23:10:44 +1200
committerChip Salzenberg <chip@atlantic.net>1997-01-29 18:11:00 +1200
commit68e56a5514edd0ab7f8a5f3ecd75c49a6ca1246e (patch)
treed3dba1f1606a963147b76ae1556d19da482f1baa /lib/Text
parent376006fe1682ba322666d5e40355d33fffc63418 (diff)
downloadperl-68e56a5514edd0ab7f8a5f3ecd75c49a6ca1246e.tar.gz
Refresh Text::Wrap to 97.011701
Diffstat (limited to 'lib/Text')
-rw-r--r--lib/Text/Wrap.pm28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/Text/Wrap.pm b/lib/Text/Wrap.pm
index 96ccf7ee2d..0910a2ab34 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 <muir@idiom.com> with help from Tim Pierce and
@@ -101,6 +111,8 @@ others.
=cut
+Latest change by Andreas Koenig <k@anna.in-berlin.de> - 1/17/97
+
print fill($initial_tab, $subsequent_tab, @text);
print fill("", "", `cat book`);