Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing Text::Wrap::break causes Text::Wrap::wrap() to fail #7867

Closed
p5pRT opened this issue Apr 9, 2005 · 6 comments
Closed

Changing Text::Wrap::break causes Text::Wrap::wrap() to fail #7867

p5pRT opened this issue Apr 9, 2005 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 9, 2005

Migrated from rt.perl.org#34902 (status was 'resolved')

Searchable as RT34902$

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2005

From eric.moyer@bigfoot.com

Created by eric_moyer@yahoo.com

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.

I did not bother to try to upgrade my perl to 5.8.5 because no delta for Text​::Wrap was mentioned.

I have attached a text version of this bug-report and minimalProblems.pl which is the code to reproduce the bug.

***********************************
* Output of code to reproduce bug *
***********************************
This works​:
(1) Category (2 or greater) New Category
This doesn't work​:
This shouldn't happen at /usr/share/perl/5.8/Text/Wrap.pm line 64.
*************************
* Code to reproduce bug *
*************************
#!/usr/bin/perl
#Causes Text​::Wrap to die...
use warnings;
use strict;
use Text​::Wrap;
my $toPrint = "(1) Category\t(2 or greater) New Category\n\n";
print "This works​:\n";
local($Text​::Wrap​::break) = '\s';
$toPrint = wrap("","",$toPrint);
print $toPrint;
print "This doesn't work​:\n";
local($Text​::Wrap​::break) = '\d';
$toPrint = wrap("","",$toPrint);
print $toPrint;
print "This doesn't work​:\n";
local($Text​::Wrap​::break) = 'a';
$toPrint = wrap("","",$toPrint);
print $toPrint;

Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.4:
Configured by Debian Project at Tue Mar  8 20:31:23 EST 2005.
Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
  Platform:
    osname=linux, osvers=2.4.27-ti1211, archname=i386-linux-thread-multi
    uname='linux kosh 2.4.27-ti1211 #1 sun sep 19 18:17:45 est 2004 i686 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.4 -Dsitearch=/usr/local/lib/perl/5.8.4 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.4 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.3.5 (Debian 1:3.3.5-9)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so.5.8.4
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
    

@INC for perl v5.8.4:
    /etc/perl
    /usr/local/lib/perl/5.8.4
    /usr/local/share/perl/5.8.4
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.8
    /usr/share/perl/5.8
    /usr/local/lib/site_perl
    .

Environment for perl v5.8.4:
    HOME=/home/eric
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/eric/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash



		
---------------------------------
Do you Yahoo!?
 Yahoo! Small Business - Try our new resources site! 

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2005

From eric.moyer@bigfoot.com

Created by eric_moyer@yahoo.com

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.

***********************************
* Output of code to reproduce bug *
***********************************

This works​:
(1) Category (2 or greater) New Category
This doesn't work​:
This shouldn't happen at /usr/share/perl/5.8/Text/Wrap.pm line 64.

*************************
* Code to reproduce bug *
*************************

#!/usr/bin/perl
#Causes Text​::Wrap to die...
use warnings;
use strict;
use Text​::Wrap;

my $toPrint = "(1) Category\t(2 or greater) New Category\n\n";

print "This works​:\n";
local($Text​::Wrap​::break) = '\s';
$toPrint = wrap("","",$toPrint);
print $toPrint;

print "This doesn't work​:\n";
local($Text​::Wrap​::break) = '\d';
$toPrint = wrap("","",$toPrint);
print $toPrint;

print "This doesn't work​:\n";
local($Text​::Wrap​::break) = 'a';
$toPrint = wrap("","",$toPrint);
print $toPrint;

Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.4:

Configured by Debian Project at Tue Mar  8 20:31:23 EST 2005.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
  Platform:
    osname=linux, osvers=2.4.27-ti1211, archname=i386-linux-thread-multi
    uname='linux kosh 2.4.27-ti1211 #1 sun sep 19 18:17:45 est 2004 i686 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.4 -Dsitearch=/usr/local/lib/perl/5.8.4 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.4 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.3.5 (Debian 1:3.3.5-9)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so.5.8.4
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.4:
    /etc/perl
    /usr/local/lib/perl/5.8.4
    /usr/local/share/perl/5.8.4
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.8
    /usr/share/perl/5.8
    /usr/local/lib/site_perl
    .


Environment for perl v5.8.4:
    HOME=/home/eric
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/eric/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2005

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2005

From @iabyn

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 davem@​davem-splatty 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';
}

-@​tests = (split(/\nEND\n/s, <<DONE));
+@​tests = (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 davem@​davem-splatty 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);

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT p5pRT closed this as completed Apr 21, 2005
@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2005

@iabyn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant