Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.84k stars 522 forks source link

Text::Wrap::wrap does not handle multiline strings properly #2073

Closed p5pRT closed 20 years ago

p5pRT commented 23 years ago

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

Searchable as RT3359$

p5pRT commented 23 years ago

From mlh@swl.msd.ray.com

To​: perlbug@​perl.com Subject​: Text​::Wrap​::wrap does not handle multiline strings properly Cc​: mlh@​swl.msd.ray.com Reply-To​: webtools@​caess5.msd.ray.com

This is a bug report for perl from webtools@​caess5.msd.ray.com\, generated with the help of perlbug 1.28 running under perl v5.6.0.


The wrap function in Text​::Wrap does not handle multiline strings properly. For example\, the following shell command


perl -e 'use Text​::Wrap; $Text​::Wrap​::columns = 10; \   print wrap ""\, ""\, \   "This_line_is_longer_than_ten_characters\n\nfoo\nbar\n";'


produces this result to stdout​:


foo bar This_line _is_longe r_than_te n_charact ers


One would hope the order of the text to be preserved!

Here is a simple test script (not sure if it fits in the test framework).

use Text​::Wrap; $Text​::Wrap​::columns = 10; $s = wrap(""\, ""\, "This_line_is_longer_than_ten_characters\n\nfoo\nbar\n"); if ($s =~ /^This/) {   print "Text​::Wrap handles multiline strings properly.\n";   exit(0); } else {   die "Text​::Wrap doesn't handle multiline strings properly.\n"; }

And here is a patch in context diff format.

*** Wrap.pm.dist Fri Jun 9 12​:12​:46 2000 --- Wrap.pm Fri Jun 9 12​:13​:29 2000 *************** *** 33\,39 ****   my $remainder = "";

  while ($t !~ /^\s*$/) { ! if ($t =~ s/^([^\n]{0\,$ll})($break|\Z(?!\n))//xm) {   $r .= unexpand($nl . $lead . $1);   $remainder = $2;   } elsif ($huge eq 'wrap' && $t =~ s/^([^\n]{$ll})//) { --- 33\,39 ----   my $remainder = "";

  while ($t !~ /^\s*$/) { ! if ($t =~ s/^([^\n]{0\,$ll})($break|\Z(?!\n))//x) {   $r .= unexpand($nl . $lead . $1);   $remainder = $2;   } elsif ($huge eq 'wrap' && $t =~ s/^([^\n]{$ll})//) {



Flags​:   category=library   severity=low


Site configuration information for perl v5.6.0​:

Configured by webtools at Thu Jun 8 10​:26​:06 EDT 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration​:   Platform​:   osname=solaris\, osvers=2.7\, archname=sun4-solaris   uname='sunos caess5 5.7 generic_106541-08 sun4u sparc sunw\,ultra-4 '   config_args='-d -Dcc=/local/users/webtools/GNUgcc/root/usr/local/bin/gcc -Dpr efix=/local/app/perl'   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef   useperlio=undef d_sfio=undef uselargefiles=define   use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef   Compiler​:   cc='/local/users/webtools/GNUgcc/root/usr/local/bin/gcc'\, optimize='-O'\, gccv ersion=2.95.2 19991024 (release)   cppflags='-fno-strict-aliasing -I/usr/local/include'   ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FI LE_OFFSET_BITS=64'   stdchar='char'\, d_stdstdio=define\, usevfork=false   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=16   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize= 8   alignbytes=8\, usemymalloc=y\, prototype=define   Linker and Libraries​:   ld='/local/users/webtools/GNUgcc/root/usr/local/bin/gcc'\, ldflags =' -L/usr/l ocal/lib '   libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib   libs=-lsocket -lnsl -ldl -lm -lc -lcrypt -lsec   libc=/lib/libc.so\, so=so\, useshrplib=false\, libperl=libperl.a   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags=' '   cccdlflags='-fPIC'\, lddlflags='-G -L/usr/local/lib'

Locally applied patches​:


@​INC for perl v5.6.0​:   /local/app/perl/lib/5.6.0/sun4-solaris   /local/app/perl/lib/5.6.0   /local/app/perl/lib/site_perl/5.6.0/sun4-solaris   /local/app/perl/lib/site_perl/5.6.0   /local/app/perl/lib/site_perl   .


Environment for perl v5.6.0​:   HOME=/local/users/webtools   LANG (unset)   LANGUAGE (unset)  
LD_LIBRARY_PATH=/usr2/app/oracle/product/8.1.6/lib​:/usr/lib​:/usr/openwin/lib​: /share/local/webcitis/lib​:/share/apl/sparcworks/C++/SUNWspro/lib​:/share/apl/orbix /lib   LOGDIR (unset)  
PATH=/local/app/perl/bin​:/local/app/apache/bin​:.​:/usr/dt/bin​:/local/users/web tools/bin.Solaris​:/bin​:/usr/bin​:/usr/sbin​:/etc​:/usr/etc​:/usr/proc/bin​:/share/apl/ gnu/bin​:/share/apl/gnu/lib​:/share/apl/perl/bin​:/share/apl/sparcworks/Pro_C_3.0.1/ SUNWspro/bin​:/share/apl/netscape​:/usr/ucb​:/usr/bin/X11​:/usr/openwin/bin​:/usr/atri a/bin​:/usr/atria/bin​:/usr2/app/oracle/product/8.1.6/bin​:/usr2/app/oracle/product/ 8.1.6/precomp​:/usr2/app/oracle/product/8.1.6/precomp/lib​:/share/apl/purify​:/share /apl/adobe/acrodist/AcroDist_2.1/bin​:/share/apl/adobe/acroreader/bin​:/share/apl/a dobe/acroexch/bin​:/share/apl/CenterLine/bin​:/usr/ccs/bin​:/usr/ccs/lib​:/share/loan /Orbix_2.0/corba2/bin​:/share/loan/Orbix_2.0​:/share/loan/Orbix_2.0/corba2   PERL=/share/apl/perl   PERL_BADLANG (unset)   SHELL=/bin/csh