develooper Front page | perl.perl5.porters | Postings from April 2007

[perl #42276] Text::Parsewords quotewords will die on really long strings

From:
Rudd Hardesty
Date:
April 2, 2007 18:56
Subject:
[perl #42276] Text::Parsewords quotewords will die on really long strings
Message ID:
rt-3.6.HEAD-1687-1175536679-1803.42276-75-0@perl.org
# New Ticket Created by  Rudd Hardesty 
# Please include the string:  [perl #42276]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42276 >


When using the Text::Parsewords module, and quotewords, it will die when
it encounters a really long string of text.  Here is an example
script.  Increase the "7" in "$num < 7" to force it to crash.

#!/usr/local/bin/perl -w
# Generates a line "Section One","01234567890123456789...etc"
use Text::ParseWords;
my $line = "\"Section One\",\"";  # "Section One","
my $total = 0;
my $num = 0;
my $tens = 0;
while ( $tens < 3276 ) {
  $line .= $num;   # append the number 0-9 to end of string
  $num++;
  $total++;
  if ( $num > 9 ) {
    $tens++;  # increase the tens by one
    $num = 0; # reset the numbers back to zero.
  }
}  # repeat until you have added 32760 characters
while ( $num < 7 ) {
  $line .= $num;  # append the numbers 0-7, to push it over the edge
  $num++;
  $total++;
}
$line .= "\"";  # put closing quote at end of string.
print "TOTAL characters: $total\n";
my @Test = &quotewords(',', 0, $line) or die "Cannot quotewords: $!\n";



[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.6.1:

Configured by ActiveState at Mon Jun 17 21:32:50 2002.

Summary of my perl5 (revision 5 version 6 subversion 1) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_IMPLICIT_CONTEX
T -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
    optimize='-O1 -MD -DNDEBUG',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -release  -libpath:"C:/Perl\lib\CORE"  -machine:x86'
    libpth="C:\Perl\lib\CORE"
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.
lib oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release  -libpath:"C:/Perl\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY

---
@INC for perl v5.6.1:
    C:/Perl/lib
    C:/Perl/site/lib
    .

---
Environment for perl v5.6.1:
    HOME=U:/
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=.;V:/Views/hardesty_rm_23snap/vip_common/config_mgmt/bin;V:/Views/hardesty_rm_23snap/vip_common/misc/win32_scri
pts;V:/Views/hardesty_rm_23snap/tap_source/dev_tools/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/IDE;
C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/To
ols;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/Tools/bin;V:/Views/hardesty_rm_23snap/tap_config/Config/J
RE/win32/bin/client;C:/Perl/bin/;C:/MKS/bin;C:/MKS/bin/x11;C:/MKS/mksnt;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System
32/Wbem;C:/Program Files/ATI Technologies/ATI Control Panel;C:/Program Files/Rational/ClearCase/bin;C:/Program Files/Rat
ional/common;C:/Program Files/Hummingbird/Connectivity/10.00/Accessories/;C:/Program Files/Hummingbird/Connectivity/10.0
0/NFS Maestro/;r:/local/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/bin;C:/Program Files/Microsoft Visual
 Studio .NET 2003/Common7/Tools/bin;C:/Program Files/Microsoft Visual Studio .NET 2003/Common7/IDE;V:/Views/hardesty_rm_
23snap/third_party/TrollTech/Qt/WINDOWS/bin;V:/Views/hardesty_rm_23snap/third_party/TrollTech/Qt/WINDOWS/lib
    PERL_BADLANG (unset)
    SHELL=C:/MKS/mksnt/sh.exe


 
---------------------------------
Don't be flakey. Get Yahoo! Mail for Mobile and 
always stay connected to friends.


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About