Skip Menu |
 

This queue is for tickets about the File-Slurp CPAN distribution.

Report information
The Basics
Id: 9403
Status: resolved
Priority: 0/
Queue: File-Slurp

People
Owner: uri [...] sysarch.com
Requestors: chris+rt [...] chrisdolan.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 9999.06
Fixed in: (no value)



Subject: Dataloss bug: append_file("filename", "") truncates the file
Download (untitled) / with headers
text/plain 3.5k
Using File::Slurp 9999.06, the append_file() function truncates the file if the empty string is passed as the content. $ perl -MFile::Slurp -e'append_file("foo", "bar\n")' $ cat foo bar $ perl -MFile::Slurp -e'append_file("foo", "bar\n")' $ cat foo bar bar $ perl -MFile::Slurp -e'append_file("foo", "")' $ cat foo $ The expected result is "bar\nbar\n" instead of "". I suspect the problem is in the sysseek() call in write_file. Perhaps write_file should short cut out in append mode where the content has length zero. ------------------------- Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Platform: osname=linux, osvers=2.4.21-1.1931.2.382.entsmp, archname=i386-linux-thread-multi uname='linux stripples.devel.redhat.com 2.4.21-1.1931.2.382.entsmp #1 smp wed aug 6 17:18:52 edt 2003 i686 i686 i386 gnulinux ' config_args='-des -Doptimize=-O2 -g -pipe -march=i386 -mcpu=i686 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Dotherlibdirs=/usr/lib/perl5/5.8.0 -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr' 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='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', optimize='-O2 -g -pipe -march=i386 -mcpu=i686', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm' ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)', 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='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.3.2' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT Locally applied patches: MAINT18379 Built under linux Compiled at Aug 13 2003 11:47:58 @INC: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .
From: Chris Dolani File::Slurp
Download (untitled) / with headers
text/plain 3.8k
[CDOLAN - Tue Jan 4 15:56:45 2005]: Show quoted text
> Using File::Slurp 9999.06, the append_file() function truncates the > file if the empty string is passed as the content. > > $ perl -MFile::Slurp -e'append_file("foo", "bar\n")' > $ cat foo > bar > $ perl -MFile::Slurp -e'append_file("foo", "bar\n")' > $ cat foo > bar > bar > $ perl -MFile::Slurp -e'append_file("foo", "")' > $ cat foo > $ > > The expected result is "bar\nbar\n" instead of "". I suspect the > problem is in the sysseek() call in write_file. Perhaps write_file > should short cut out in append mode where the content has length > zero. > > ------------------------- > > Summary of my perl5 (revision 5.0 version 8 subversion 0) > configuration: > Platform: > osname=linux, osvers=2.4.21-1.1931.2.382.entsmp, archname=i386- > linux-thread-multi > uname='linux stripples.devel.redhat.com 2.4.21-1.1931.2.382.entsmp > #1 smp wed aug 6 17:18:52 edt 2003 i686 i686 i386 gnulinux ' > config_args='-des -Doptimize=-O2 -g -pipe -march=i386 -mcpu=i686 > -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc > -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr > -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr > -Dotherlibdirs=/usr/lib/perl5/5.8.0 -Duseshrplib -Dusethreads > -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db > -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio > -Dinstallusrbinperl -Ubincompat5005 -Uversiononly > -Dpager=/usr/bin/less -isr' > 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='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS > -DDEBUGGING -fno-strict-aliasing -I/usr/local/include > -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', > optimize='-O2 -g -pipe -march=i386 -mcpu=i686', > cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS > -DDEBUGGING -fno-strict-aliasing -I/usr/local/include > -I/usr/include/gdbm' > ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)', > 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='gcc', ldflags =' -L/usr/local/lib' > libpth=/usr/local/lib /lib /usr/lib > libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil > perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil > libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, > libperl=libperl.so > gnulibc_version='2.3.2' > Dynamic Linking: > dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='- > rdynamic > -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE' > cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' > > > Characteristics of this binary (from libperl): > Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS > USE_LARGE_FILES PERL_IMPLICIT_CONTEXT > Locally applied patches: > MAINT18379 > Built under linux > Compiled at Aug 13 2003 11:47:58 > @INC: > /usr/lib/perl5/5.8.0/i386-linux-thread-multi > /usr/lib/perl5/5.8.0 > /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi > /usr/lib/perl5/site_perl/5.8.0 > /usr/lib/perl5/site_perl > /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi > /usr/lib/perl5/vendor_perl/5.8.0 > /usr/lib/perl5/vendor_perl > /usr/lib/perl5/5.8.0/i386-linux-thread-multi > /usr/lib/perl5/5.8.0 > .
From: Chris Dolan
This bug still exists in the latest version, 9999.07
From: Chris Dolan
This bug still exists in the latest version, 9999.08


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.