From: Steve Peters Date: Tue, 11 Jul 2006 12:31:10 +0000 (+0000) Subject: Upgrade to Text-Tabs+Wrap-2006.0711. Keep the local changes from X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=95925ace7dd478659af55ea84cc2d7e598cbf885;hp=9e4425f7401960922972922c0fbf30ed45522d5e;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Text-Tabs+Wrap-2006.0711. Keep the local changes from change #27541. Also, leave out the test files Jacobson.t and Jacobson2.t which both generated several warnings. p4raw-link: @27541 on //depot/perl: abc0156ba8cc024916c0d1e664c4488f0cbc55c8 p4raw-id: //depot/perl@28546 --- diff --git a/MANIFEST b/MANIFEST index 80b072d..7856c0d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2532,7 +2532,13 @@ lib/Text/Soundex.pm Perl module to implement Soundex lib/Text/Soundex.t See if Soundex works lib/Text/Tabs.pm Do expand and unexpand lib/Text/TabsWrap/CHANGELOG ChangeLog for Tabs+Wrap +lib/Text/TabsWrap/t/37000.t See if Text::Tabs is working +lib/Text/TabsWrap/t/39548.t See if Text::Tabs is working +lib/Text/TabsWrap/t/Jochen.t See if Text::Tabs is working +lib/Text/TabsWrap/t/belg4mit.t See if Text::Tabs is working lib/Text/TabsWrap/t/fill.t See if Text::Wrap::fill works +lib/Text/TabsWrap/t/sep.t See if Text::Tabs is working +lib/Text/TabsWrap/t/sep2.t See if Text::Tabs is working lib/Text/TabsWrap/t/tabs.t See if Text::Tabs works lib/Text/TabsWrap/t/wrap.t See if Text::Wrap::wrap works lib/Text/Wrap.pm Paragraph formatter diff --git a/lib/Text/Tabs.pm b/lib/Text/Tabs.pm index aa79ecc..ab54c77 100644 --- a/lib/Text/Tabs.pm +++ b/lib/Text/Tabs.pm @@ -7,7 +7,7 @@ require Exporter; @EXPORT = qw(expand unexpand $tabstop); use vars qw($VERSION $tabstop $debug); -$VERSION = 2005.0824; +$VERSION = 2007.0711_01; use strict; @@ -44,15 +44,17 @@ sub unexpand my $line; my @lines; my $lastbit; + my $ts_as_space = " "x$tabstop; for $x (@l) { @lines = split("\n", $x, -1); for $line (@lines) { $line = expand($line); @e = split(/(.{$tabstop})/,$line,-1); $lastbit = pop(@e); - $lastbit = '' unless defined $lastbit; + $lastbit = '' + unless defined $lastbit; $lastbit = "\t" - if $lastbit eq " "x$tabstop; + if $lastbit eq $ts_as_space; for $_ (@e) { if ($debug) { my $x = $_; @@ -95,17 +97,35 @@ Text::Tabs -- expand and unexpand tabs per the unix expand(1) and unexpand(1) use Text::Tabs; - $tabstop = 4; + $tabstop = 4; # default = 8 @lines_without_tabs = expand(@lines_with_tabs); @lines_with_tabs = unexpand(@lines_without_tabs); =head1 DESCRIPTION -Text::Tabs does about what the unix utilities expand(1) and unexpand(1) +Text::Tabs does about what the unix utilities expand(1) and unexpand(1) do. Given a line with tabs in it, expand will replace the tabs with the appropriate number of spaces. Given a line with or without tabs in -it, unexpand will add tabs when it can save bytes by doing so. Invisible -compression with plain ascii! +it, unexpand will add tabs when it can save bytes by doing so (just +like C). Invisible compression with plain ASCII! + +=head1 EXAMPLE + + #!perl + # unexpand -a + use Text::Tabs; + + while (<>) { + print unexpand $_; + } + +Instead of the C comand, use: + + perl -MText::Tabs -n -e 'print expand $_' + +Instead of the C command, use: + + perl -MText::Tabs -n -e 'print unexpand $_' =head1 BUGS @@ -114,7 +134,7 @@ entire document in one string. Instead feed it an array of lines. =head1 LICENSE -Copyright (C) 1996-2002,2005 David Muir Sharnoff. +Copyright (C) 1996-2002,2005,2006 David Muir Sharnoff. Copyright (C) 2005 Aristotle Pagaltzis This module may be modified, used, copied, and redistributed at your own risk. Publicly redistributed modified versions must use a different name. diff --git a/lib/Text/TabsWrap/CHANGELOG b/lib/Text/TabsWrap/CHANGELOG index 0ca0a19..f82e584 100644 --- a/lib/Text/TabsWrap/CHANGELOG +++ b/lib/Text/TabsWrap/CHANGELOG @@ -1,3 +1,25 @@ += 2006/07/11 + +Further bomb-proofing to pass more tests: Dan Jacobson found another way to generate a "this shouldn't happen". + += 2006/07/05 + +Made documentation and code changes to address perlbug: +https://rt.perl.org/rt3/Ticket/Display.html?id=30229 + +Added in changes from the distributed-with-perl version. This took +care of perlbug: https://rt.perl.org/rt3/Ticket/Display.html?id=34902 +It also took care of suggestion from Matthijs Bomhoff . + +Made documentation changes (added EXAMPLES) as per a suggestion +from Gabor Blasko + +belg4mit at MIT dot EDU reported that $columns==1 die'd. No longer. + +Added tests for each bug report. + = 2005/08/24 Added $separator2 and tests for $separator and $separator2 diff --git a/lib/Text/TabsWrap/t/37000.t b/lib/Text/TabsWrap/t/37000.t new file mode 100755 index 0000000..1efbc70f --- /dev/null +++ b/lib/Text/TabsWrap/t/37000.t @@ -0,0 +1,29 @@ +#!/usr/bin/perl -I. + +#Causes Text::Wrap to die... +use warnings; +use strict; +use Text::Wrap; + +my $toPrint = "(1) Category\t(2 or greater) New Category\n\n"; +my $good = "(1) Category\t(2 or greater) New Category\n"; + +my $toprint; + +print "1..6\n"; + +local($Text::Wrap::break) = '\s'; +eval { $toPrint = wrap("","",$toPrint); }; +print $@ ? "not ok 1\n" : "ok 1\n"; +print $toPrint eq $good ? "ok 2\n" : "not ok 2\n"; + +local($Text::Wrap::break) = '\d'; +eval { $toPrint = wrap("","",$toPrint); }; +print $@ ? "not ok 3\n" : "ok 3\n"; +print $toPrint eq $good ? "ok 4\n" : "not ok 4\n"; + +local($Text::Wrap::break) = 'a'; +eval { $toPrint = wrap("","",$toPrint); }; +print $@ ? "not ok 5\n" : "ok 5\n"; +print $toPrint eq $good ? "ok 6\n" : "not ok 6\n"; + diff --git a/lib/Text/TabsWrap/t/39548.t b/lib/Text/TabsWrap/t/39548.t new file mode 100755 index 0000000..6cca086 --- /dev/null +++ b/lib/Text/TabsWrap/t/39548.t @@ -0,0 +1,11 @@ +#!/usr/bin/perl -w -I. + +# https://rt.perl.org/rt3/Ticket/Display.html?id=39548 + +print "1..1\n"; +require Text::Wrap; +$VAR1 = " (Karl-Bonhoeffer-Nervenklinik zwischen Hermann-Piper-Str. und U-Bahnhof) "; +$VAR2 = " "; +$VAR3 = "(5079,19635 5124,19634 5228,19320 5246,19244)\n"; +eval { Text::Wrap::wrap($VAR1,$VAR2,$VAR3); }; +print $@ ? "not ok 1\n" : "ok 1\n"; diff --git a/lib/Text/TabsWrap/t/Jochen.t b/lib/Text/TabsWrap/t/Jochen.t new file mode 100755 index 0000000..d4a3a8b --- /dev/null +++ b/lib/Text/TabsWrap/t/Jochen.t @@ -0,0 +1,11 @@ +#!/usr/bin/perl -I. + +use Text::Wrap; + +print "1..1\n"; + +$Text::Wrap::columns = 1; +eval { wrap('', '', ''); }; + +print $@ ? "not ok 1\n" : "ok 1\n"; + diff --git a/lib/Text/TabsWrap/t/belg4mit.t b/lib/Text/TabsWrap/t/belg4mit.t new file mode 100755 index 0000000..2d10342 --- /dev/null +++ b/lib/Text/TabsWrap/t/belg4mit.t @@ -0,0 +1,18 @@ +#!/usr/bin/perl -I. + +use Text::Wrap; + +print "1..1\n"; + +$Text::Wrap::columns = 1; +eval { wrap('', '', 'H4sICNoBwDoAA3NpZwA9jbsNwDAIRHumuC4NklvXTOD0KSJEnwU8fHz4Q8M9i3sGzkS7BBrm +OkCTwsycb4S3DloZuMIYeXpLFqw5LaMhXC2ymhreVXNWMw9YGuAYdfmAbwomoPSyFJuFn2x8 +Opr8bBBidccAAAA'); }; + +if ($@) { + my $e = $@; + $e =~ s/^/# /gm; + print $e; +} +print $@ ? "not ok 1\n" : "ok 1\n"; + diff --git a/lib/Text/TabsWrap/t/fill.t b/lib/Text/TabsWrap/t/fill.t index 3d5b98f..dab0432 100755 --- a/lib/Text/TabsWrap/t/fill.t +++ b/lib/Text/TabsWrap/t/fill.t @@ -1,11 +1,4 @@ -#!./perl -w - -BEGIN { - chdir 't' if -d 't'; - @INC = '../lib'; -} - -use Text::Wrap qw(&fill); +#!/usr/bin/perl -w -I. @tests = (split(/\nEND\n/s, < $huge = 'overflow'; B - + use Text::Wrap $Text::Wrap::columns = 72; @@ -160,6 +164,8 @@ 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(). +Both C and C return a single string. + =head1 OVERRIDES C has a number of variables that control its behavior. @@ -208,15 +214,35 @@ left intact. Historical notes: 'die' used to be the default value of C<$huge>. Now, 'wrap' is the default value. -=head1 EXAMPLE +=head1 EXAMPLES + +Code: + + print wrap("\t","",< with help from Tim Pierce and -many many others. Copyright (C) 1996-2002 David Muir Sharnoff. +many many others. Copyright (C) 1996-2006 David Muir Sharnoff. This module may be modified, used, copied, and redistributed at your own risk. Publicly redistributed modified versions must use a different name.