Perl / perl5

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

join blows away SvUTF8 on first argument #1502

Closed p5pRT closed 20 years ago

p5pRT commented 24 years ago

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

Searchable as RT2716$

p5pRT commented 24 years ago

From @TimToady

Created by larry@kiev.wall.org

The following demonstrates the bug.

  #!./perl

  $x = v2001.2002.2003;

  @​x = unpack 'U*'\, $x;   print "@​x\n";

  $x = join ''\, map { chr } @​x;

  printf "%vd\n"\, $x;

This prints​:

  2001 2002 2003   223.145.2002.2003

With the fix\, it prints​:

  2001 2002 2003   2001.2002.2003

Here's the fix​:

*** doop.c.orig Sat Mar 25 15​:29​:00 2000 --- doop.c Sat Mar 25 15​:31​:17 2000 *************** *** 660\,671 ****   if (items-- > 0) {   char *s;  
! if (*mark) { ! s = SvPV(*mark\, tmplen); ! sv_setpvn(sv\, s\, tmplen); ! } ! else ! sv_setpv(sv\, "");   mark++;   }   else --- 660\,668 ----   if (items-- > 0) {   char *s;  
! sv_setpv(sv\, ""); ! if (*mark) ! sv_catsv(sv\, *mark);   mark++;   }   else

Perl Info ``` This perlbug was built using Perl 5.00502 - Tue Jan 26 23:37:16 PST 1999 It is being executed now by Perl 5.006 - Fri Mar 24 09:37:57 PST 2000. Site configuration information for perl 5.006: Configured by larry at Fri Mar 24 09:37:57 PST 2000. Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=solaris, osvers=2.5.1, archname=sun4-solaris uname='sunos kiev 5.5.1 generic sun4u sparc sunw,ultra-1 ' config_args='-de -Dcc=gcc -Doptimize=-g' 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='gcc', optimize='-g', gccversion=2.8.1 cppflags='-DDEBUGGING -I/usr/local/include' ccflags ='-DDEBUGGING -I/usr/local/include ' stdchar='unsigned 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=4 alignbytes=8, usemymalloc=y, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib ' libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -lgdbm -ldb -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: REPLACE_PREFIX - allows editing binary to change PREFIX @INC for perl 5.006: /usr/local/lib/perl5/5.6.0/sun4-solaris /usr/local/lib/perl5/5.6.0 /usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris /usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl/5.00552/sun4-solaris /usr/local/lib/perl5/site_perl/5.00552 /usr/local/lib/perl5/site_perl/5.005/sun4-solaris /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl . Environment for perl 5.006: HOME=/home/larry LANG (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/larry/bin:/home/larry/pl:/usr/sbin:/usr/ccs/bin:/usr/ucb:/bin:/usr/bin:/usr/local/bin:/home/scripts:/usr/bin/X11:/usr/etc:/work/bin:/work/src/jdk1.1.1/bin:/usr/local/frame/bin:/usr/local/pbmplus:/usr/openwin/bin:/usr/openwin/bin/xview:/usr/openwin/demo:. PERL_BADLANG (unset) SHELL=/usr/local/bin/tcsh ```