On Sat, Apr 09, 2005 at 10:13:11PM -0000, eric. moyer @ bigfoot. com wrote:
> When I change the break variable of $Text::Wrap, it dies with the
> message "This should not happen."  This happens unless I change the
> value to its default of '\s' and also happens if I use a compiled
> reg-ex rather than a string.

Thanks for the report. It turns out that Text::Wrap couldn't cope with
separators that didn't include whitespace. Fixed in bleedperl by the
change below.

I also fixed a few typos in the documentation while I was at it.

Dave.

-- 
Technology is dominated by two types of people: those who understand what
they do not manage, and those who manage what they do not understand. 


Change 24273 by [EMAIL PROTECTED] on 2005/04/21 21:22:54

        [perl #34902] Text::Wrap::wrap() fails with non-space separator

Affected files ...

... //depot/perl/lib/Text/TabsWrap/t/wrap.t#3 edit
... //depot/perl/lib/Text/Wrap.pm#22 edit

Differences ...

==== //depot/perl/lib/Text/TabsWrap/t/wrap.t#3 (xtext) ====

@@ -5,7 +5,7 @@
     @INC = '../lib';
 }
 
[EMAIL PROTECTED] = (split(/\nEND\n/s, <<DONE));
[EMAIL PROTECTED] = (split(/\nEND\n/s, <<'DONE'));
 TEST1
 This 
 is
@@ -117,6 +117,17 @@
  Lines
 
 END
+TEST13 break=\d
+I saw 3 ships come sailing in
+END
+   I saw 3 ships come sailing in
+END
+TEST14 break=\d
+the.quick.brown.fox.jumps.over.the.9.lazy.dogs.for.no.good.reason.whatsoever.apparently
+END
+   the.quick.brown.fox.jumps.over.the.
+ .lazy.dogs.for.no.good.reason.whatsoever.apparently
+END
 DONE
 
 
@@ -135,7 +146,9 @@
        my $in = shift(@st);
        my $out = shift(@st);
 
-       $in =~ s/^TEST(\d+)?\n//;
+       $in =~ s/^TEST(\d+)( break=(.*))?\n//
+           or die "bad TEST header line: $in\n";
+       local $Text::Wrap::break = $3 if defined $3;
 
        my $back = wrap('   ', ' ', $in);
 
@@ -169,7 +182,10 @@
        my $in = shift(@st);
        my $out = shift(@st);
 
-       $in =~ s/^TEST(\d+)?\n//;
+       $in =~ s/^TEST(\d+)( break=(.*))?\n//
+           or die "bad TEST header line: $in\n";
+       local $Text::Wrap::break = $3 if defined $3;
+
 
        my @in = split("\n", $in, -1);
        @in = ((map { "$_\n" } @in[0..$#in-1]), $in[-1]);

==== //depot/perl/lib/Text/Wrap.pm#22 (text) ====

@@ -43,7 +43,7 @@
 
        pos($t) = 0;
        while ($t !~ /\G\s*\Z/gc) {
-               if ($t =~ /\G([^\n]{0,$ll})($break|\z)/xmgc) {
+               if ($t =~ /\G([^\n]{0,$ll})($break|\n*\z)/xmgc) {
                        $r .= $unexpand 
                                ? unexpand($nl . $lead . $1)
                                : $nl . $lead . $1;
@@ -151,7 +151,7 @@
 
 Text::Wrap::fill() is a simple multi-paragraph formatter.  It formats
 each paragraph separately and then joins them together when it's done.  It
-will destory any whitespace in the original text.  It breaks text into
+will destroy any whitespace in the original text.  It breaks text into
 paragraphs by looking for whitespace after a newline.  In other respects
 it acts like wrap().
 
@@ -183,12 +183,12 @@
 C<Text::Wrap::wrap()> starts its work by expanding all the tabs in its
 input into spaces.  The last thing it does it to turn spaces back
 into tabs.  If you do not want tabs in your results, set 
-C<$Text::Wrap::unexapand> to a false value.  Likewise if you do not
+C<$Text::Wrap::unexpand> to a false value.  Likewise if you do not
 want to use 8-character tabstops, set C<$Text::Wrap::tabstop> to
 the number of characters you do want for your tabstops.
 
 If you want to separate your lines with something other than C<\n>
-then set C<$Text::Wrap::seporator> to your preference.
+then set C<$Text::Wrap::separator> to your preference.
 
 When words that are longer than C<$columns> are encountered, they
 are broken up.  C<wrap()> adds a C<"\n"> at column C<$columns>.


Change 24275 by [EMAIL PROTECTED] on 2005/04/21 21:30:11

        Sigh - really bump Text::Wrap version number this time.


Affected files ...

... //depot/perl/lib/Text/Wrap.pm#24 edit

Differences ...

==== //depot/perl/lib/Text/Wrap.pm#24 (text) ====

@@ -6,7 +6,7 @@
 @EXPORT = qw(wrap fill);
 @EXPORT_OK = qw($columns $break $huge);
 
-$VERSION = 2001.09292;
+$VERSION = 2001.09293;
 
 use vars qw($VERSION $columns $debug $break $huge $unexpand $tabstop
        $separator);

Reply via email to